Open michalbundyra opened 4 years ago
During bootstrap, we have not yet executed the router, so there are no route match parameters yet. If you invoke the plugin, and it's attempting to use defaults, it will fail due to the lack of parameters.
I cannot reproduce the reported error by only pulling the plugin, however; are you sure you're not doing something else within the onBootstrap()
method? I have the code you indicate above, and am getting successful returns at this time.
Originally posted by @weierophinney at https://github.com/zfcampus/zf-apigility-admin/issues/294#issuecomment-119365008
Ah! So I've done much digging only to find this already-reported. I've minimized anything additional and come up with this:
config/application.config.php
modules should look like this: array(
'ZF\\Apigility',
'ZF\\Apigility\\Provider',
'ZF\\Apigility\\Documentation',
'AssetManager',
'ZF\\ApiProblem',
'ZF\\MvcAuth',
'ZF\\OAuth2',
'ZF\\Hal',
'ZF\\ContentNegotiation',
'ZF\\ContentValidation',
'ZF\\Rest',
'ZF\\Rpc',
'ZF\\Versioning',
'Test',
)
module/Test/src/Test/Module.php
: public function onBootstrap($e)
{
$app = $e->getTarget();
$services = $app->getServiceManager();
$helpers = $services->get('ViewHelperManager');
$helpers->get('Hal');
}
https://{{ application }}/api/apigility/api/module/Test/rest?version=1
or go directly.Expected:
{
"_links": {
"self": {
"href": "https://{{ application }}/api/apigility/api/module/Test/rest?version=1"
}
},
"_embedded": {
"rest": [
{
"accept_whitelist": [
"application/vnd.test.v1+json",
"application/hal+json",
"application/json"
],
"collection_class": "Test\\V1\\Rest\\Test\\TestCollection",
"collection_http_methods": [
"GET",
"POST"
],
"collection_name": "test",
"collection_query_whitelist": [],
"content_type_whitelist": [
"application/vnd.test.v1+json",
"application/json"
],
"controller_service_name": "Test-V1-Rest-Test-Controller",
"entity_class": "Test\\V1\\Rest\\Test\\TestEntity",
"entity_http_methods": [
"GET",
"PATCH",
"PUT",
"DELETE"
],
"entity_identifier_name": "id",
"hydrator_name": "Zend\\Stdlib\\Hydrator\\ArraySerializable",
"module": "Test",
"page_size_param": null,
"page_size": 25,
"resource_class": "Test\\V1\\Rest\\Test\\TestResource",
"route_identifier_name": "test_id",
"route_match": "/test[/:test_id]",
"route_name": "test.rest.test",
"selector": "HalJson",
"service_name": "Test",
"_links": {
"self": {
"href": "https://{{ application }}/api/apigility/api/module/Test/rest/Test-V1-Rest-Test-Controller"
},
"input_filter": {
"href": "https://{{ application }}/api/apigility/api/module/Test/rest/Test-V1-Rest-Test-Controller/input-filter"
},
"documentation": {
"href": "https://{{ application }}/api/apigility/api/module/Test/rest/Test-V1-Rest-Test-Controller/doc"
}
}
}
]
},
"total_items": 1
}
Actual:
{
"status": 500,
"title": "Unexpected error",
"describedBy": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"detail": "Missing parameter \"name\"",
"details": {
"code": 0,
"message": "Missing parameter \"name\"",
"trace": "#0 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/Segment.php(313): Zend\\Mvc\\Router\\Http\\Segment->buildPath(Array, Array, true, true, Array)\n#1 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/Segment.php(409): Zend\\Mvc\\Router\\Http\\Segment->buildPath(Array, Array, false, true, Array)\n#2 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/Part.php(197): Zend\\Mvc\\Router\\Http\\Segment->assemble(Array, Array)\n#3 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/TreeRouteStack.php(331): Zend\\Mvc\\Router\\Http\\Part->assemble(Array, Array)\n#4 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/Part.php(210): Zend\\Mvc\\Router\\Http\\TreeRouteStack->assemble(Array, Array)\n#5 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/TreeRouteStack.php(331): Zend\\Mvc\\Router\\Http\\Part->assemble(Array, Array)\n#6 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/Part.php(210): Zend\\Mvc\\Router\\Http\\TreeRouteStack->assemble(Array, Array)\n#7 /var/www/app/vendor/zendframework/zend-mvc/src/Router/Http/TreeRouteStack.php(352): Zend\\Mvc\\Router\\Http\\Part->assemble(Array, Array)\n#8 /var/www/app/vendor/zendframework/zend-view/src/Helper/Url.php(100): Zend\\Mvc\\Router\\Http\\TreeRouteStack->assemble(Array, Array)\n#9 [internal function]: Zend\\View\\Helper\\Url->__invoke('zf-apigility/ap...', Array, Array, true)\n#10 /var/www/app/vendor/zfcampus/zf-hal/src/Extractor/LinkExtractor.php(85): call_user_func(Object(Zend\\View\\Helper\\Url), 'zf-apigility/ap...', Array, Array, true)\n#11 /var/www/app/vendor/zfcampus/zf-hal/src/Extractor/LinkCollectionExtractor.php(52): ZF\\Hal\\Extractor\\LinkExtractor->extract(Object(ZF\\Hal\\Link\\Link))\n#12 /var/www/app/vendor/zfcampus/zf-hal/src/Plugin/Hal.php(718): ZF\\Hal\\Extractor\\LinkCollectionExtractor->extract(Object(ZF\\Hal\\Link\\LinkCollection))\n#13 /var/www/app/vendor/zfcampus/zf-hal/src/Plugin/Hal.php(729): ZF\\Hal\\Plugin\\Hal->fromLinkCollection(Object(ZF\\Hal\\Link\\LinkCollection))\n#14 /var/www/app/vendor/zfcampus/zf-hal/src/Plugin/Hal.php(495): ZF\\Hal\\Plugin\\Hal->fromResource(Object(ZF\\Hal\\Collection))\n#15 /var/www/app/vendor/zfcampus/zf-hal/src/View/HalJsonRenderer.php(119): ZF\\Hal\\Plugin\\Hal->renderCollection(Object(ZF\\Hal\\Collection))\n#16 /var/www/app/vendor/zendframework/zend-view/src/View.php(205): ZF\\Hal\\View\\HalJsonRenderer->render(Object(ZF\\Hal\\View\\HalJsonModel))\n#17 /var/www/app/vendor/zendframework/zend-mvc/src/View/Http/DefaultRenderingStrategy.php(103): Zend\\View\\View->render(Object(ZF\\Hal\\View\\HalJsonModel))\n#18 [internal function]: Zend\\Mvc\\View\\Http\\DefaultRenderingStrategy->render(Object(Zend\\Mvc\\MvcEvent))\n#19 /var/www/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\\Mvc\\MvcEvent))\n#20 /var/www/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\\EventManager\\EventManager->triggerListeners('render', Object(Zend\\Mvc\\MvcEvent), Array)\n#21 /var/www/app/vendor/zendframework/zend-mvc/src/Application.php(353): Zend\\EventManager\\EventManager->trigger('render', Object(Zend\\Mvc\\MvcEvent))\n#22 /var/www/app/vendor/zendframework/zend-mvc/src/Application.php(328): Zend\\Mvc\\Application->completeRequest(Object(Zend\\Mvc\\MvcEvent))\n#23 /var/www/app/public/index.php(44): Zend\\Mvc\\Application->run()\n#24 {main}"
}
}
Originally posted by @robob4him at https://github.com/zfcampus/zf-apigility-admin/issues/294#issuecomment-140900397
I'm having the same issue. I've tried fiddling a bit with the versions of the dependencies and it starts occurring when switching to version 1.5.x.
Originally posted by @rokkie at https://github.com/zfcampus/zf-apigility-admin/issues/294#issuecomment-239619680
Any solutions?
Originally posted by @esilvajr at https://github.com/zfcampus/zf-apigility-admin/issues/294#issuecomment-259676243
I have a strange error. As documentation say, I've done something like this to add a Link in an entity:
Just getting the
Hal
plugin, the route/api/module/:name/rest/:controller_service_name
is broken with the error messageMissing parameter "name"
and the following stack trace:Seems that route params are not passed correctly to the
TreeRouteStack
, but I don't know why it's happening when I get theHal
plugin on my module bootstrap.Originally posted by @thomasvargiu at https://github.com/zfcampus/zf-apigility-admin/issues/294