-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I have an odd case where the entity (hal resource) has a property name that is also (sometimes) the name of a link and embedded object. Basically a message can be sent by a user (which a link and embedded object exist for), or a non-user where some basic information had been gathered to identify them (but no link or embedded resource because they're not an user).
Quick example:
{
"sender": {
"name": "Test User",
"number": "15556667878"
},
"_links": {
"sender": {
"href": "http://example.com/users/12345"
}
},
"_embedded": {
"sender": {
"id": "12345",
"name": "Test User",
"number": "15556667878"
}
}
}
Because the hydrator can send back a link collection, which is merged into the entities links during render, it's possible to have both a link and an entity property with the same name. However, it's not possible to have both a entity property and an embedded entity with the same name, since both are passed from the hydrator using a simple array.
My thought is to add support for hydrators to return an _embedded key (optionally), and anything found there will be treated as embedded entities.
If I put this together as a PR, any opposition to merging it in?
Originally posted by @tjlytle at zfcampus/zf-hal#52