Zend\Expressive\Application::getFinalHandler PHP Method

getFinalHandler() public method

Return the final handler to use during run() if the stack is exhausted.
public getFinalHandler ( Psr\Http\Message\ResponseInterface $response = null ) : callable | null
$response Psr\Http\Message\ResponseInterface Response instance with which to seed the FinalHandler; used to determine if the response passed to the handler represents the original or final response state.
return callable | null
    public function getFinalHandler(ResponseInterface $response = null)
    {
        if (!$this->finalHandler) {
            return null;
        }
        // Inject the handler with the response, if possible (e.g., the
        // TemplatedErrorHandler and WhoopsErrorHandler implementations).
        if (method_exists($this->finalHandler, 'setOriginalResponse')) {
            $this->finalHandler->setOriginalResponse($response);
        }
        return $this->finalHandler;
    }

Usage Example

 public function testCanInjectFinalHandlerViaConstructor()
 {
     $finalHandler = function ($req, $res, $err = null) {
     };
     $app = new Application($this->router->reveal(), null, $finalHandler);
     $test = $app->getFinalHandler();
     $this->assertSame($finalHandler, $test);
 }
All Usage Examples Of Zend\Expressive\Application::getFinalHandler