Skip to content

2.x Document post serialization#2335

Merged
jarednova merged 4 commits into2.x-docs-apifrom
2.x-docs-api-serialization
Oct 9, 2020
Merged

2.x Document post serialization#2335
jarednova merged 4 commits into2.x-docs-apifrom
2.x-docs-api-serialization

Conversation

@gchtr
Copy link
Copy Markdown
Member

@gchtr gchtr commented Oct 7, 2020

Ticket: #2311

Issue

As one of the final documentation issues in #2073, we should document JSON serialization of posts that was added in #2311.

Solution

Take a stab at adding an example with a book post.

Impact

Even more insights about posts and advanced Timber coding.

Usage Changes

None.

Considerations

@acobster I hope I got everything right!

Also, in #2311 (comment) you had an idea to implement jsonSerialize() in Timber\Post.

Yeah, in addition to providing some sensible default behavior in Timber\Post (I just wanted to avoid touching Post too much in this PR, and just focus on collections). Child implementations can easily call parent::jsonSerialize() to get the data to use as a basis, so we should capture that in the docs.

Right, good idea! We should definitely also have an example that explains that removing data would make sense, too, because you don’t want to fill the HTML of a page with data that has to be downloaded but that you will never need.

I’m still not sure about that, but I think it might be hard to figure out which data is added by default, because this depends sooo much on the use case. Maybe not defining a default isn’t all that bad after all?

Testing

Nope.

@gchtr gchtr force-pushed the 2.x-docs-api-serialization branch from f039142 to 3cdca62 Compare October 7, 2020 20:33
@gchtr gchtr mentioned this pull request Oct 7, 2020
24 tasks
Copy link
Copy Markdown
Member

@jarednova jarednova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few tweaks. Then I remembered that I should do it as a review instead of just going and changing things. So one more tweak I found ("implements" vs. "implement"). Otherwise this is a super clear and helpful explanation and illustration of the problem/solution.

Co-authored-by: Jared Novack <jarednova@upstatement.com>
@gchtr
Copy link
Copy Markdown
Member Author

gchtr commented Oct 9, 2020

@jarednova Thanks for checking! I think it’s totally fine to fix typos and grammatical issues directly. But suggestions work great as well 👍. I’ll leave it to you to merge this in.

@jarednova jarednova merged commit a3b24d6 into 2.x-docs-api Oct 9, 2020
@jarednova
Copy link
Copy Markdown
Member

👍

@jarednova jarednova deleted the 2.x-docs-api-serialization branch October 9, 2020 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants