diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index e0acb565648fb..8afab1ca81d49 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -51,14 +51,35 @@ public function showAction(Request $request, FlattenException $exception, DebugL $code = $exception->getStatusCode(); + $originalRequest = $request->attributes->get('original_request'); + + // allow the developer to see the real template with ?_real_template=1 + $debug = $this->debug; + if ($debug && $originalRequest && $originalRequest->query->get('_real_template')) { + $debug = false; + } + + // determine if we're able to show the link to view the true error template + $showErrorTemplateLink = false; + $errorTemplateParams = array(); + if ($originalRequest && $originalRequest->isMethod('GET')) { + $showErrorTemplateLink = true; + $errorTemplateParams = array_merge( + $request->query->all(), + array('_real_template' => 1) + ); + } + return new Response($this->twig->render( - $this->findTemplate($request, $_format, $code, $this->debug), + $this->findTemplate($request, $_format, $code, $debug), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, + 'showErrorTemplateLink' => $showErrorTemplateLink, + 'errorTemplateParams' => $errorTemplateParams, ) )); } diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig index 1920b6008b117..9b0c0d54bc35a 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig @@ -11,3 +11,16 @@ {% block body %} {% include 'TwigBundle:Exception:exception.html.twig' %} {% endblock %} + +{% block header_right %} + {% if showErrorTemplateLink %} + + + Render True Error Page + + + {% endif %} +{% endblock %} diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig index 69409827057d0..b98913f57743c 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig @@ -31,6 +31,8 @@ + + {% block header_right %}{% endblock %} diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 3450b6210ce07..b51a15cd7abbf 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -114,6 +114,7 @@ protected function duplicateRequest(\Exception $exception, Request $request) '_controller' => $this->controller, 'exception' => FlattenException::create($exception), 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, + 'original_request' => $request, // keep for BC -- as $format can be an argument of the controller callable // see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php // @deprecated in 2.4, to be removed in 3.0