Esempio n. 1
0
 /**
  * Determine the parameters to pass to the view layer.
  *
  * Overwrite it in a custom ExceptionController class to add additionally parameters
  * that should be passed to the view layer.
  *
  * @param ViewHandler                                       $viewHandler    The view handler instance
  * @param string                                            $currentContent The current content in the output buffer
  * @param integer                                           $code           An HTTP response code
  * @param HttpFlattenException|DebugFlattenException        $exception      A HttpFlattenException|DebugFlattenException instance
  * @param DebugLoggerInterface                              $logger         A DebugLoggerInterface instance
  * @param string                                            $format         The format to use for rendering (html, xml, ...)
  *
  * @return array Template parameters
  */
 protected function getParameters(ViewHandler $viewHandler, $currentContent, $code, $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $parameters = array('status' => 'error', 'status_code' => $code, 'status_text' => array_key_exists($code, Response::$statusTexts) ? Response::$statusTexts[$code] : "error", 'currentContent' => $currentContent, 'message' => $this->getExceptionMessage($exception));
     if ($viewHandler->isFormatTemplating($format)) {
         $parameters['exception'] = $exception;
         $parameters['logger'] = $logger;
     }
     return $parameters;
 }
 /**
  * Determines the parameters to pass to the view layer.
  *
  * Overwrite it in a custom ExceptionController class to add additionally parameters
  * that should be passed to the view layer.
  *
  * @param ViewHandler                                $viewHandler
  * @param string                                     $currentContent
  * @param int                                        $code
  * @param HttpFlattenException|DebugFlattenException $exception
  * @param DebugLoggerInterface                       $logger
  * @param string                                     $format
  *
  * @return array
  */
 protected function getParameters(ViewHandler $viewHandler, $currentContent, $code, $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $parameters = array('status' => 'error', 'status_code' => $code, 'status_text' => array_key_exists($code, Response::$statusTexts) ? Response::$statusTexts[$code] : "error", 'currentContent' => $currentContent, 'message' => $this->getExceptionMessage($exception), 'exception' => $exception);
     /*
      * Extra info for ApiExceptions
      */
     if ($exception instanceof ApiExceptionInterface) {
         $parameters['id'] = $exception->getId();
         $parameters['info'] = $exception->getInfo();
         $parameters['category'] = $exception->getCategory();
         $parameters['errors'] = $exception->getErrors();
     }
     if ($viewHandler->isFormatTemplating($format)) {
         $parameters['logger'] = $logger;
     }
     return $parameters;
 }