My routes def:
'router' => [
'routes' => [
'TimeTable' => [
'type' => 'Literal',
'options' => [
// Change this to something specific to your module
'route' => '/tt',
],
'may_terminate' => false,
'child_routes' => [
'API' => [
'type' => 'Literal',
'options' => [
// Change this to something specific to your module
'route' => '/api',
],
'may_terminate' => false,
'child_routes' => [
'lines' => [
'type' => 'Literal',
'options' => [
// Change this to something specific to your module
'route' => '/lines',
'defaults' => [
'controller' => Controller\LineRestApiController::class,
],
],
'may_terminate' => true,
],
],
],
],
],
],
Medatada map def:
MetadataMap::class => [
[
'__class__' => RouteBasedCollectionMetadata::class,
'collection_class' => LineCollection::class,
'collection_relation' => 'lines',
'route' => 'TimeTable/API/Lines',
],
]
Generated result:
{
"_total_items": 78,
"_page": 1,
"_page_count": 4,
"_links": {
"self": {
"href": "http://xxx.xxx.xx"
},
"next": {
"href": "http://xxx.xxx.xx"
},
"last": {
"href": "http://xxx.xxx.xx"
}
},
"_embedded": {
"lines": [.....] }}
All links are generated with incomplete href , there is only domain part, route part is stripped ..
Expected result is something like this:
"href" : "http://xxx.xxx.xx/xxx/tt/api/lines....."
Im doing something wrong, I have no idea where to start ..
Thanks everyone for giving me some ideas
Simplified Controller code:
$psr7request = Psr7ServerRequest::fromZend($this->getRequest());
$list = this->entityManager->getRepository(Line::class)->getValidLinesCollection();
$resource = $this->resourceGenerator->fromObject($list, $psr7request);
echo Psr7Response::toZend($this->responseFactory->createResponse($psr7request, $resource))->getBody();
exit;
PS: Im not using full zend-expressive just zend-framework..
Sorry i forgot that i had done in last week :(
It must be done some custom implementation for UrlGeneratorInterface to successful integrate zend-expressive-hal to zend framework (original class ExpressiveUrlGenerator uses Expressive\Helper\ServerUrlHelper & UrlHelper, the part of Expressive)
So i used Zend\View\Helper\ServerUrl & Url to done it.
I have small typo in code. The final class is here:
I hope the code can help somebody.