bug #11904 Make twig ExceptionController conformed with ExceptionListener (megazoll)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11904).

Discussion
----------

Make twig ExceptionController conformed with ExceptionListener

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #9083
| License       | MIT
| Doc PR        |

Parameter passed to exception controller from exception listener called ``format``, so variable ``_format`` in exception controller always takes default value.
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L120

Commits
-------

24c5ba4 Use request format from request in twig ExceptionController
This commit is contained in:
Fabien Potencier 2014-09-24 09:29:50 +02:00
commit d0537e0efb
1 changed files with 2 additions and 3 deletions

View File

@ -39,20 +39,19 @@ class ExceptionController
* @param Request $request The request
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param string $_format The format to use for rendering (html, xml, ...)
*
* @return Response
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
{
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$code = $exception->getStatusCode();
return new Response($this->twig->render(
$this->findTemplate($request, $_format, $code, $this->debug),
$this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',