Hi everyone!
I have been trying to register a Listener for ViewEvent::EVENT_RENDERER_POST
, and I have hit a wall.
This is what I have:
PostRendererListener:
<?php
namespace Application\Listener;
use Laminas\EventManager\AbstractListenerAggregate;
use Laminas\EventManager\EventManagerInterface;
use Laminas\View\ViewEvent;
class PostRendererListener extends AbstractListenerAggregate
{
public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(
ViewEvent::EVENT_RENDERER_POST,
[$this, 'onRendererPost']
);
}
public function onRendererPost(ViewEvent $event)
{
echo "foo"; // i set a breakpoint here, which has no effect
$event->getApplication();
}
}
?>
I am wiring this up into the container in the module.config.php:
'service_manager' => [
'factories' => [
\Application\Listener\PostRendererListener::class => InvokableFactory::class
]
],
'listeners' => [
\Application\Listener\PostRendererListener::class,
]
Now, the event is triggered in Laminas\View\View. The responsible eventmanager in that class comes from the ViewFactory of laminas-mvc, where it is retrieved from the Container, which should include all listeners registered under listeners
in the appConfig according to Application.php#init().
Does anybody notice what I am missing? Thanks!