我为onKernelResponse创建了一个EventListener:
<?php
namespace Webprogest\More\SharedBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
class RequestListener
{
protected $sc;
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function onKernelResponse(FilterResponseEvent $event)
{
$response = $event->getResponse();
var_dump($response);
}
}
这是我的service.yml:
kernel.listener.your_listener_name:
class: Webprogest\More\SharedBundle\EventListener\RequestListener
arguments: ["@service_container"]
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
- { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }
我的问题是:当然,在调用Controller之前,在调用视图之前触发此事件的次数的99%。那么:我如何访问我发送到控制器视图的$ data数组? 感谢