Преглед на файлове

[FrameworkBundle] Ensuring the exception page renders even when the Request format is unknown to Symfony

Jordi Boggiano преди 14 години
родител
ревизия
e7ea2eb433
променени са 1 файла, в които са добавени 9 реда и са изтрити 2 реда
  1. 9 2
      src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php

+ 9 - 2
src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php

@@ -46,8 +46,15 @@ class ExceptionController extends ContainerAware
             $exception->setStatusCode($exception->getCode());
         }
 
-        $response = $this->container->get('templating')->renderResponse(
-            'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php'),
+        $templating = $this->container->get('templating');
+        $template = 'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php');
+
+        if (!$templating->exists($template)) {
+            $this->container->get('request')->setRequestFormat('html');
+        }
+
+        $response = $templating->renderResponse(
+            $template,
             array(
                 'exception'      => $exception,
                 'logger'         => $logger,