mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-27 17:28:39 +00:00
Customize errors templates
All error goes to the same template which only display the error message and the status code.
This commit is contained in:
parent
114c55c0a6
commit
40e219622a
7 changed files with 107 additions and 9 deletions
40
src/Wallabag/CoreBundle/Controller/ExceptionController.php
Normal file
40
src/Wallabag/CoreBundle/Controller/ExceptionController.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\TwigBundle\Controller\ExceptionController as BaseExceptionController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* This controller allow us to customize the error template.
|
||||
* The only modified line from the parent template is for "WallabagCoreBundle".
|
||||
*/
|
||||
class ExceptionController extends BaseExceptionController
|
||||
{
|
||||
protected function findTemplate(Request $request, $format, $code, $showException)
|
||||
{
|
||||
$name = $showException ? 'exception' : 'error';
|
||||
if ($showException && 'html' == $format) {
|
||||
$name = 'exception_full';
|
||||
}
|
||||
|
||||
// For error pages, try to find a template for the specific HTTP status code and format
|
||||
if (!$showException) {
|
||||
$template = sprintf('WallabagCoreBundle:Exception:%s.%s.twig', $name, $format);
|
||||
if ($this->templateExists($template)) {
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
// try to find a template for the given format
|
||||
$template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format);
|
||||
if ($this->templateExists($template)) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
// default to a generic HTML exception
|
||||
$request->setRequestFormat('html');
|
||||
|
||||
return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue