]>
Commit | Line | Data |
---|---|---|
40e21962 JB |
1 | <?php |
2 | ||
3 | namespace Wallabag\CoreBundle\Controller; | |
4 | ||
5 | use Symfony\Bundle\TwigBundle\Controller\ExceptionController as BaseExceptionController; | |
6 | use Symfony\Component\HttpFoundation\Request; | |
7 | ||
8 | /** | |
9 | * This controller allow us to customize the error template. | |
10 | * The only modified line from the parent template is for "WallabagCoreBundle". | |
11 | */ | |
12 | class ExceptionController extends BaseExceptionController | |
13 | { | |
14 | protected function findTemplate(Request $request, $format, $code, $showException) | |
15 | { | |
16 | $name = $showException ? 'exception' : 'error'; | |
f808b016 | 17 | if ($showException && 'html' === $format) { |
40e21962 JB |
18 | $name = 'exception_full'; |
19 | } | |
20 | ||
21 | // For error pages, try to find a template for the specific HTTP status code and format | |
22 | if (!$showException) { | |
23 | $template = sprintf('WallabagCoreBundle:Exception:%s.%s.twig', $name, $format); | |
24 | if ($this->templateExists($template)) { | |
25 | return $template; | |
26 | } | |
27 | } | |
28 | ||
29 | // try to find a template for the given format | |
30 | $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format); | |
31 | if ($this->templateExists($template)) { | |
32 | return $template; | |
33 | } | |
34 | ||
35 | // default to a generic HTML exception | |
36 | $request->setRequestFormat('html'); | |
37 | ||
38 | return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name); | |
39 | } | |
40 | } |