Zend\Stratigility\FinalHandler::__invoke PHP Метод

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

This handler should only ever be invoked if Next exhausts its stack. When that happens, one of three possibilities exists: - If an $err is present, create a 500 status with error details. - If the instance composes a response, and it differs from the response passed during invocation, return the invocation response; this is indicative of middleware calling $next to allow post-processing of a populated response. - Otherwise, a 404 status is created.
public __invoke ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, mixed $err = null ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\RequestInterface Request instance.
$response Psr\Http\Message\ResponseInterface Response instance.
$err mixed
Результат Psr\Http\Message\ResponseInterface
    public function __invoke(RequestInterface $request, ResponseInterface $response, $err = null)
    {
        if ($err) {
            return $this->handleError($err, $request, $response);
        }
        // Return provided response if it does not match the one provided at
        // instantiation; this is an indication of calling `$next` in the final
        // registered middleware and providing a new response instance.
        if ($this->response && $this->response !== $response) {
            return $response;
        }
        // If the response passed is the same as the one at instantiation,
        // check to see if the body size has changed; if it has, return
        // the response, as the message body has been written to.
        if ($this->response && $this->response === $response && $this->bodySize !== $response->getBody()->getSize()) {
            return $response;
        }
        return $this->create404($request, $response);
    }