/** * * {@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(); }
/** * * {@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; }
/** * * {@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()); }
/** * * {@inheritDoc} * * @see \Nia\Routing\Condition\ConditionInterface::checkCondition($request, $context) */ public function checkCondition(RequestInterface $request, MapInterface $context) : bool { return $request->getArguments()->has($this->argumentName); }
/** * * {@inheritDoc} * * @see \Nia\Routing\Condition\ConditionInterface::checkCondition($request, $context) */ public function checkCondition(RequestInterface $request, MapInterface $context) : bool { return $this->method === $request->getMethod(); }