Zend\Mvc\View\Http\ExceptionStrategy::prepareExceptionViewModel PHP Метод

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

Create an exception view model, and set the HTTP status code
public prepareExceptionViewModel ( MvcEvent $e ) : void
$e Zend\Mvc\MvcEvent
Результат void
    public function prepareExceptionViewModel(MvcEvent $e)
    {
        // Do nothing if no error in the event
        $error = $e->getError();
        if (empty($error)) {
            return;
        }
        // Do nothing if the result is a response object
        $result = $e->getResult();
        if ($result instanceof Response) {
            return;
        }
        switch ($error) {
            case Application::ERROR_CONTROLLER_NOT_FOUND:
            case Application::ERROR_CONTROLLER_INVALID:
            case Application::ERROR_ROUTER_NO_MATCH:
                // Specifically not handling these
                return;
            case Application::ERROR_EXCEPTION:
            default:
                $model = new ViewModel(['message' => 'An error occurred during execution; please try again later.', 'exception' => $e->getParam('exception'), 'display_exceptions' => $this->displayExceptions()]);
                $model->setTemplate($this->getExceptionTemplate());
                $e->setResult($model);
                $response = $e->getResponse();
                if (!$response) {
                    $response = new HttpResponse();
                    $response->setStatusCode(500);
                    $e->setResponse($response);
                } else {
                    $statusCode = $response->getStatusCode();
                    if ($statusCode === 200) {
                        $response->setStatusCode(500);
                    }
                }
                break;
        }
    }