RouterListener
class RouterListener implements EventSubscriberInterface
Initializes the context from the request and sets request attributes based on a matching route.
This listener works in 2 modes:
- 2.3 compatibility mode where you must call setRequest whenever the Request changes.
- 2.4+ mode where you must pass a RequestStack instance in the constructor.
Methods
__construct(UrlMatcherInterface|RequestMatcherInterface $matcher, RequestStack $requestStack = null, RequestContext|null $context = null, LoggerInterface|null $logger = null) RequestStack will become required in 3.0. | ||
setRequest(Request $request = null) deprecated Sets the current Request. | ||
onKernelFinishRequest(FinishRequestEvent $event) | ||
onKernelRequest(GetResponseEvent $event) | ||
static array | getSubscribedEvents() Returns an array of event names this subscriber wants to listen to. |
Details
__construct(UrlMatcherInterface|RequestMatcherInterface $matcher, RequestStack $requestStack = null, RequestContext|null $context = null, LoggerInterface|null $logger = null)
RequestStack will become required in 3.0.
Parameters
UrlMatcherInterface|RequestMatcherInterface | $matcher | The Url or Request matcher |
RequestStack | $requestStack | A RequestStack instance |
RequestContext|null | $context | The RequestContext (can be null when $matcher implements RequestContextAwareInterface) |
LoggerInterface|null | $logger | The logger |
Exceptions
InvalidArgumentException |
setRequest(Request $request = null) deprecated
deprecated
Sets the current Request.
This method was used to synchronize the Request, but as the HttpKernel is doing that automatically now, you should never call it directly. It is kept public for BC with the 2.3 version.
Parameters
Request | $request | A Request instance |
onKernelFinishRequest(FinishRequestEvent $event)
Parameters
FinishRequestEvent | $event |
onKernelRequest(GetResponseEvent $event)
Parameters
GetResponseEvent | $event |
static array getSubscribedEvents()
Returns an array of event names this subscriber wants to listen to.
The array keys are event names and the value can be:
- The method name to call (priority defaults to 0)
- An array composed of the method name to call and the priority
- An array of arrays composed of the method names to call and respective priorities, or 0 if unset
For instance:
- array('eventName' => 'methodName')
- array('eventName' => array('methodName', $priority))
- array('eventName' => array(array('methodName1', $priority), array('methodName2')))
Return Value
array | The event names to listen to |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/HttpKernel/EventListener/RouterListener.html