/**
  *
  * {@inheritDoc}
  *
  * @see \Nia\Routing\Filter\FilterInterface::filterRequest($request, $context)
  */
 public function filterRequest(RequestInterface $request, WriteableMapInterface $context) : ResponseInterface
 {
     $matches = [];
     if (preg_match($this->regex, $request->getPath(), $matches)) {
         // extract only named matches.
         $data = array_intersect_key($matches, array_flip(array_filter(array_keys($matches), 'is_string')));
         foreach ($data as $name => $value) {
             $context->set($name, $value);
         }
     }
     throw new IgnoreFilterException();
 }
 public function fooBarAction(RequestInterface $request, WriteableMapInterface $context) : ResponseInterface
 {
     return $request->createResponse();
 }
예제 #3
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Nia\Routing\Condition\ConditionInterface::checkCondition($request, $context)
  */
 public function checkCondition(RequestInterface $request, MapInterface $context) : bool
 {
     return preg_match($this->regex, $request->getPath()) !== 0;
 }
예제 #4
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Nia\Routing\Condition\ConditionInterface::checkCondition($request, $context)
  */
 public function checkCondition(RequestInterface $request, MapInterface $context) : bool
 {
     return $this->path === $request->getPath();
 }
 /**
  * @covers \Nia\RequestResponse\Cli\CliRequest::createResponse
  */
 public function testCreateResponse()
 {
     $this->assertInstanceOf(CliResponseInterface::class, $this->request->createResponse());
 }
예제 #6
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Nia\Routing\Condition\ConditionInterface::checkCondition($request, $context)
  */
 public function checkCondition(RequestInterface $request, MapInterface $context) : bool
 {
     return $request->getArguments()->has($this->argumentName);
 }
예제 #7
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Nia\Routing\Condition\ConditionInterface::checkCondition($request, $context)
  */
 public function checkCondition(RequestInterface $request, MapInterface $context) : bool
 {
     return $this->method === $request->getMethod();
 }