Open weierophinney opened 4 years ago
Further Information:
The problem exists, if I my resources returns an paginator object.
So the "magic" of zf-hal try's to generate the links
for every entity in the collection based on the mapping_data
configuration. But it doesn't set the parameters required by the route.
Originally posted by @FrankGiesecke at https://github.com/zfcampus/zf-hal/issues/140#issuecomment-202294716
As far as I know the real bug is that the RouteMatch is not set in the URL helper. Workaround:
public function onBootstrap(MvcEvent $event)
{
$eventManager = $event->getApplication()->getEventManager();
$eventManager->attach(MvcEvent::EVENT_ROUTE, [$this, 'onSetRouteMatch'], -1);
}
public function onSetRouteMatch(MvcEvent $event)
{
$viewHelpers = $event->getApplication()->getServiceManager()->get('ViewHelperManager');
$viewHelpers->get('url')->setRouteMatch($event->getRouteMatch());
}
This is because the route params are reused but there is not route match available because it's not set in the url helper.
Originally posted by @waltertamboer at https://github.com/zfcampus/zf-hal/issues/140#issuecomment-375599533
When using the
metadata_map
to create further links, there is a problem with the route parameters.Following config:
If you query a single resource from
lists.rest.list (/rest/list/1)
the links will generated perfectly.But if you query the collection from
lists.rest.list (/rest/list)
you will receive an error.The reason is, that in this case the route param
listId
is unknown.I thought, that the param should be set based on the mapping configuration (
route_identifier_name
andentity_identifier_name
).Is there an error in the configuration? Or is there a bug in the mapping?
Originally posted by @FrankGiesecke at https://github.com/zfcampus/zf-hal/issues/140