aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 14:51:54 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 14:58:48 +0200
commit40e219622a2c416ab36cb39b26a5e1354e4438cc (patch)
tree878fb4e50ecee04603f8a05dec04f9a4b8662d18 /src/Wallabag/CoreBundle/Controller
parent114c55c0a6eade2ba6c53fe25f61cc58cca91620 (diff)
downloadwallabag-40e219622a2c416ab36cb39b26a5e1354e4438cc.tar.gz
wallabag-40e219622a2c416ab36cb39b26a5e1354e4438cc.tar.zst
wallabag-40e219622a2c416ab36cb39b26a5e1354e4438cc.zip
Customize errors templates
All error goes to the same template which only display the error message and the status code.
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-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}