|
11 | 11 |
|
12 | 12 | namespace FOS\RestBundle\Controller; |
13 | 13 |
|
14 | | -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; |
15 | 14 | use Symfony\Component\HttpFoundation\Request; |
16 | 15 |
|
17 | 16 | /** |
@@ -42,27 +41,27 @@ protected function findTemplate(Request $request, $statusCode, $showException) |
42 | 41 | $format = $request->getRequestFormat(); |
43 | 42 |
|
44 | 43 | $name = $showException ? 'exception' : 'error'; |
45 | | - if ($showException && 'html' === $format) { |
| 44 | + if ($showException && 'html' == $format) { |
46 | 45 | $name = 'exception_full'; |
47 | 46 | } |
48 | 47 |
|
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 |
50 | 49 | if (!$showException) { |
51 | | - $template = new TemplateReference('TwigBundle', 'Exception', $name.$statusCode, $format, 'twig'); |
| 50 | + $template = sprintf('@Twig/Exception/%s%s.%s.twig', $name, $statusCode, $format); |
52 | 51 | if ($this->templating->exists($template)) { |
53 | 52 | return $template; |
54 | 53 | } |
55 | 54 | } |
56 | 55 |
|
57 | 56 | // 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); |
59 | 58 | if ($this->templating->exists($template)) { |
60 | 59 | return $template; |
61 | 60 | } |
62 | 61 |
|
63 | 62 | // default to a generic HTML exception |
64 | 63 | $request->setRequestFormat('html'); |
65 | 64 |
|
66 | | - return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig'); |
| 65 | + return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name); |
67 | 66 | } |
68 | 67 | } |
0 commit comments