Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Conversation

@rmccue
Copy link
Member

@rmccue rmccue commented Feb 27, 2015

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.

This allows it to be reused in other places.
Rather than having to handle this in each parent, makes sense to handle
it here.
@rmccue
Copy link
Member Author

rmccue commented Feb 27, 2015

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 WP_JSON_Response instances, and embed from there instead. Does that sound like a better approach? I'm not fussed either way, but that does mean special-casing at the server level.

@rmccue rmccue added this to the 2.0 milestone Feb 27, 2015
@rmccue rmccue added the Bug label Feb 27, 2015
@rmccue rmccue self-assigned this Feb 27, 2015
@danielbachhuber
Copy link
Member

My current thinking on how links should be added is that the Server should sniff attributes with relation=<named-route> and auto-populate _links based on those defined attributes. I think relation=<named-route> will scale well, and solve validation problems too, etc.

@rmccue rmccue modified the milestones: 2.0 Beta 1, 2.0 Apr 7, 2015
# Conflicts:
#	lib/endpoints/class-wp-json-controller.php
#	lib/endpoints/class-wp-json-posts-controller.php
@rachelbaker
Copy link
Member

@rmccue The links cannot be embedded from collection responses with this PR. Should we remove the embeddable key when returning a collection response for now?

@rachelbaker
Copy link
Member

I added collection links to the following endpoints:

  • Media
  • Comments
  • Users

We currently don't appear to have any entity links for the Taxonomies or Terms endpoints. Anything else we are missing here?

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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.

@danielbachhuber
Copy link
Member

Seems like this would be a good opportunity to add more test coverage.

@rachelbaker
Copy link
Member

I added support for Terms links, and am kicking this back to @rmccue to see what else he wants to do here.

rachelbaker added a commit that referenced this pull request Apr 23, 2015
@rachelbaker rachelbaker merged commit a6aaf1b into develop Apr 23, 2015
@rachelbaker rachelbaker deleted the display-links-in-collections branch April 23, 2015 01:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post _links are not available from collection

4 participants