public function RouterListener::__construct in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-kernel/EventListener/RouterListener.php \Symfony\Component\HttpKernel\EventListener\RouterListener::__construct()
Constructor.
RequestStack will become required in 3.0.
Parameters
UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher:
RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface):
LoggerInterface|null $logger The logger:
RequestStack|null $requestStack A RequestStack instance:
Throws
\InvalidArgumentException
File
- vendor/
symfony/ http-kernel/ EventListener/ RouterListener.php, line 60
Class
- RouterListener
- Initializes the context from the request and sets request attributes based on a matching route.
Namespace
Symfony\Component\HttpKernel\EventListenerCode
public function __construct($matcher, RequestContext $context = null, LoggerInterface $logger = null, RequestStack $requestStack = null) {
if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) {
throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.');
}
if (null === $context && !$matcher instanceof RequestContextAwareInterface) {
throw new \InvalidArgumentException('You must either pass a RequestContext or the matcher must implement RequestContextAwareInterface.');
}
if (!$requestStack instanceof RequestStack) {
@trigger_error('The ' . __METHOD__ . ' method now requires a RequestStack instance as ' . __CLASS__ . '::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED);
}
$this->matcher = $matcher;
$this->context = $context ?: $matcher
->getContext();
$this->requestStack = $requestStack;
$this->logger = $logger;
}