Skip to content

Commit c9e25ef

Browse files
committed
Fix exception controller
1 parent c7fd5d6 commit c9e25ef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Controller/TwigExceptionController.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace FOS\RestBundle\Controller;
1313

14-
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
1514
use Symfony\Component\HttpFoundation\Request;
1615

1716
/**
@@ -42,27 +41,27 @@ protected function findTemplate(Request $request, $statusCode, $showException)
4241
$format = $request->getRequestFormat();
4342

4443
$name = $showException ? 'exception' : 'error';
45-
if ($showException && 'html' === $format) {
44+
if ($showException && 'html' == $format) {
4645
$name = 'exception_full';
4746
}
4847

49-
// when not in debug, try to find a template for the specific HTTP status code and format
48+
// For error pages, try to find a template for the specific HTTP status code and format
5049
if (!$showException) {
51-
$template = new TemplateReference('TwigBundle', 'Exception', $name.$statusCode, $format, 'twig');
50+
$template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $statusCode, $format);
5251
if ($this->templating->exists($template)) {
5352
return $template;
5453
}
5554
}
5655

5756
// try to find a template for the given format
58-
$template = new TemplateReference('TwigBundle', 'Exception', $name, $format, 'twig');
57+
$template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format);
5958
if ($this->templating->exists($template)) {
6059
return $template;
6160
}
6261

6362
// default to a generic HTML exception
6463
$request->setRequestFormat('html');
6564

66-
return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig');
65+
return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
6766
}
6867
}

0 commit comments

Comments
 (0)