Closed MichaelGooden closed 11 years ago
Ideally, we should also have a mechanism in the metadata map for specifying additional links to include in resources. This would likely require some sort of event system to allow developers to dynamically create such links (which is what you're doing here, too).
Well would you always require an event to specify your links? In my above example I could tell the metadata map the link relation, and route for my resource links. That would be all it needs to create the link on each resource. While I do see the need to have an event system in place to later possibly overwrite these links for more complex reasons, would having to do this in an event for basic links be necessary?
@MichaelGooden No -- if you have a links collection already, you would not need to trigger events, necessarily. But if there are links in the metadata for a given resource type, it would make sense. I'm mainly just making notes to myself here. :)
Fix in PR #71
In PhlyRestfully\Plugin\HalLinks::extractCollection() we do not check whether the current $resource is instanceof HalResource. The result is that if you are using a ClassMethods hydrator, the resulting array then looks like ["links"=>xx].
The reason I want to return HalResources from my $collection is so that I can compose links of sub resources using this feature.
If there is an easier way to include resource links in collections that I am missing, please advise.
Why I need this:
This is a Collection of
Contacts
. I need to have thephone
link on each of myContacts
.