aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ExceptionController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ExceptionController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExceptionController.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ExceptionController.php b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
new file mode 100644
index 00000000..abfa9c2f
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
@@ -0,0 +1,40 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Symfony\Bundle\TwigBundle\Controller\ExceptionController as BaseExceptionController;
6use 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 */
12class ExceptionController extends BaseExceptionController
13{
14 protected function findTemplate(Request $request, $format, $code, $showException)
15 {
16 $name = $showException ? 'exception' : 'error';
17 if ($showException && 'html' == $format) {
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}