PhlyRestfully icon indicating copy to clipboard operation
PhlyRestfully copied to clipboard

Route identifier_name should be a property of the metadata map

Open awartoft opened this issue 12 years ago • 2 comments
trafficstars

According to the documentation here https://phlyrestfully.readthedocs.org/en/latest/ref/advanced-routing.html one should use a metadata_map instead of using listeners.

But according to this line: https://github.com/phly/PhlyRestfully/blob/master/src/PhlyRestfully/Plugin/HalLinks.php#L558 It's extracted from the metadata identifier_name that represents the identifier for the object and not the route. thus the metadata_map can currently not solve the child routes properly.

My suggestion would be to add another parameter to the metadata mapping route_identifier_name and if it's not set assume the same as identifier_name

Suggestions on a fix @weierophinney ?

awartoft avatar Sep 17 '13 08:09 awartoft

I agree, this seems inconsistent. At one point identifier_name it is representing a route id and later an object id. It took me some time to figure this out. Another solution would be to let the identifier_name in the meta data map represent the route identifier (like done in the resource definitions) and use the getIdFromResource function defined at line 865 to get the identifier out of the object like done similarly on line 581: $id = $this->getIdFromResource($resource);

https://github.com/phly/PhlyRestfully/blob/master/src/PhlyRestfully/Plugin/HalLinks.php#L581

This solution would actually mean replacing line 544 to 552 by the same code as on line 581 to 587

Wilt avatar Oct 02 '13 10:10 Wilt

+1 i've run up against this issue also. The name of the identifier key on the resource won't necessarily be the same as the identifier key on the route.

glennschmidt avatar Oct 29 '13 11:10 glennschmidt