Open michalbundyra opened 4 years ago
I also have the same problem. This is my code(From aligility documentation https://apigility.org/documentation/modules/zf-hal) public function onBootstrap($e) { $app = $e->getTarget(); $services = $app->getServiceManager(); $helpers = $services->get('ViewHelperManager'); $hal = $helpers->get('Hal'); // The HAL plugin's EventManager instance does not compose a SharedEventManager, // so you must attach directly to it. $hal->getEventManager()->attach('renderEntity', array($this, 'onRenderEntity')); } public function onRenderEntity($e) { $entity = $e->getParam('entity'); if (! $entity->entity instanceof SomeTypeIHaveDefined) { // do nothing return; } // Add a "describedBy" relational link $entity->getLinks()->add(\ZF\Hal\Link\Link::factory(array( 'rel' => 'describedBy', 'route' => array( 'name' => 'my/api/docs', ), ))); }
Originally posted by @nebero at https://github.com/zfcampus/zf-apigility/issues/79#issuecomment-67747424
Same problem here.
Instead of
$app = $e->getTarget();
$services = $app->getServiceManager();
$helpers = $services->get('ViewHelperManager');
$hal = $helpers->get('Hal');
$hal->getEventManager()->attach('renderEntity', array($this, 'onRenderEntity'));
use
$app = $e->getTarget();
$services = $app->getServiceManager();
$sharedEvents = $services->get('SharedEventManager');
$sharedEvents->attach('ZF\Hal\Plugin\Hal', 'renderEntity', array($this, 'onRenderEntity'));
(from https://groups.google.com/a/zend.com/forum/#!msg/apigility-users/p4nm3scFxJM/D9ZjUqECYWUJ)
Originally posted by @gaco79 at https://github.com/zfcampus/zf-apigility/issues/79#issuecomment-72107723
Using the SharedEventManager in the way described by @gaco79 from the Google Groups thread fixed the problem resulting in the error message:
Missing parameter \"name\"
++ for solution.
Originally posted by @ashireman at https://github.com/zfcampus/zf-apigility/issues/79#issuecomment-103691682
+1 for solution
Originally posted by @danbroooks at https://github.com/zfcampus/zf-apigility/issues/79#issuecomment-176496552
After attaching a listener to HAL plugin event manager and trying to edit API's in /apigility/ui#/api,and clicking on an existing API, it wont load. When I comment out the onBootstrap() method in Module.php, the existing API's load normally.
The call to /apigility/api/module/FileApi/rest?version=1 fails with this response:
Originally posted by @pdizz at https://github.com/zfcampus/zf-apigility/issues/79