-
Notifications
You must be signed in to change notification settings - Fork 651
Display links in collections #937
Conversation
This allows it to be reused in other places.
Rather than having to handle this in each parent, makes sense to handle it here.
|
Note also that you can't embed items from a collection, because this is handled outside of the server. One alternative approach I've been considering: the server could check if the response data is purely a list of |
|
My current thinking on how links should be added is that the Server should sniff attributes with |
# Conflicts: # lib/endpoints/class-wp-json-controller.php # lib/endpoints/class-wp-json-posts-controller.php
|
@rmccue The links cannot be embedded from collection responses with this PR. Should we remove the |
- Dispatch the request through the server. - Only pass the response data to the check_post_data method, not the entire response object.
|
I added collection links to the following endpoints:
We currently don't appear to have any entity links for the Taxonomies or Terms endpoints. Anything else we are missing here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Why didn't this break before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WP_JSON_Response has ArrayAccess, so you can set it directly fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the parent post controller prepare_item_for_response now returns an object instead of an array. I renamed the variable because we are modifying the response data not the response itself.
|
Seems like this would be a good opportunity to add more test coverage. |
|
I added support for Terms links, and am kicking this back to @rmccue to see what else he wants to do here. |
Display links in collections
Fixes #859.
@WP-API/amigos What do you think of the approach here? There's a wee bit of duplication needed in that we're now replicating a small part of the server, but I don't think that's too big of an issue.
If we're 👍 on the approach, I'll apply the same to our other collections too.