Zend\Stratigility\Next::process PHP Метод

process() публичный Метод

public process ( Psr\Http\Message\RequestInterface $request ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\RequestInterface
Результат Psr\Http\Message\ResponseInterface
    public function process(RequestInterface $request)
    {
        $dispatch = $this->dispatch;
        $done = $this->nextDelegate;
        $request = $this->resetPath($request);
        // No middleware remains; done
        if ($this->queue->isEmpty()) {
            return $this->dispatchNextDelegate($done, $request);
        }
        $layer = $this->queue->dequeue();
        $path = $request->getUri()->getPath() ?: '/';
        $route = $layer->path;
        $normalizedRoute = strlen($route) > 1 ? rtrim($route, '/') : $route;
        // Skip if layer path does not match current url
        if (substr(strtolower($path), 0, strlen($normalizedRoute)) !== strtolower($normalizedRoute)) {
            return $this->process($request);
        }
        // Skip if match is not at a border ('/', '.', or end)
        $border = $this->getBorder($path, $normalizedRoute);
        if ($border && '/' !== $border && '.' !== $border) {
            return $this->process($request);
        }
        // Trim off the part of the url that matches the layer route
        if (!empty($route) && $route !== '/') {
            $request = $this->stripRouteFromPath($request, $route);
        }
        $result = $dispatch->process($layer, $request, $this);
        if (!$result instanceof ResponseInterface) {
            return $this->getResponsePrototype();
        }
        return $result;
    }

Usage Example

Пример #1
0
 /**
  * @todo Remove for 2.0.0, as the $done handler will no longer be used.
  * @group http-interop
  */
 public function testNextCanUseADelegateForTheDoneHandler()
 {
     $delegate = $this->prophesize(DelegateInterface::class);
     $delegate->process(Argument::type(RequestInterface::class))->willReturn('FOOBAR');
     $next = new Next($this->queue, $delegate->reveal());
     $this->assertEquals('FOOBAR', $next->process($this->request));
 }
All Usage Examples Of Zend\Stratigility\Next::process