public function RouterListener::__construct

Constructor.

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:

Throws

\InvalidArgumentException

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php, line 49

Class

RouterListener
Initializes the context from the request and sets request attributes based on a matching route.

Namespace

Symfony\Component\HttpKernel\EventListener

Code

public function __construct($matcher, RequestContext $context = null, LoggerInterface $logger = 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.');
  }
  $this->matcher = $matcher;
  $this->context = $context ?: $matcher
    ->getContext();
  $this->logger = $logger;
}