Пример #1
0
 /**
  * Constructor.
  *
  * RequestStack will become required in 3.0.
  *
  * @param UrlMatcherInterface|RequestMatcherInterface $matcher      The Url or Request matcher
  * @param RequestStack                                $requestStack A RequestStack instance
  * @param RequestContext|null                         $context      The RequestContext (can be null when $matcher implements RequestContextAwareInterface)
  * @param LoggerInterface|null                        $logger       The logger
  *
  * @throws \InvalidArgumentException
  */
 public function __construct($matcher, $requestStack = null, $context = null, $logger = null)
 {
     if ($requestStack instanceof RequestContext || $context instanceof LoggerInterface || $logger instanceof RequestStack) {
         $tmp = $requestStack;
         $requestStack = $logger;
         $logger = $context;
         $context = $tmp;
         @trigger_error('The ' . __METHOD__ . ' method now requires a RequestStack to be given as second argument as ' . __CLASS__ . '::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED);
     } elseif (!$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);
     }
     if (null !== $requestStack && !$requestStack instanceof RequestStack) {
         throw new \InvalidArgumentException('RequestStack instance expected.');
     }
     if (null !== $context && !$context instanceof RequestContext) {
         throw new \InvalidArgumentException('RequestContext instance expected.');
     }
     if (null !== $logger && !$logger instanceof LoggerInterface) {
         throw new \InvalidArgumentException('Logger must implement LoggerInterface.');
     }
     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->requestStack = $requestStack;
     $this->logger = $logger;
 }
Пример #2
0
 /**
  * Constructor.
  *
  * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher
  * @param RequestContext|null                         $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface)
  * @param LoggerInterface|null                        $logger  The logger
  *
  * @throws \InvalidArgumentException
  */
 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;
 }
 /**
  * Constructor.
  *
  * RequestStack will become required in 3.0.
  *
  * @param UrlMatcherInterface|RequestMatcherInterface $matcher      The Url or Request matcher
  * @param RequestContext|null                         $context      The RequestContext (can be null when $matcher implements RequestContextAwareInterface)
  * @param LoggerInterface|null                        $logger       The logger
  * @param RequestStack|null                           $requestStack A RequestStack instance
  *
  * @throws \InvalidArgumentException
  */
 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;
 }