Customy Exception Control not working anymore after update to Symfony 2.8

為{幸葍}努か 提交于 2019-12-11 18:08:02

问题


I have just updated my Symfony 2.7 page to 2.8. Beside Symfony itself a number of other packages (e.g. FOSUserBundle, FOSRestBundle, Doctrine, etc.) have been updated as well.

After the Update my CustomExceptionController does not work any more. Error like 404 or 500 show the default exception page instead of my custom page. Before the Update my CustomExceptionController worked without any problem.

This is the configuration:

// app/config/config.yml
...
twig:
    exception_controller:  app.exception_controller:showAction


// src/MyAppBundle/Resources/config/services.yml
app.exception_controller:
    class: MyAppBundle\Controller\CustomExceptionController
    arguments: ['@twig', '%kernel.debug%', "@translator.default" ]


// src/MyAppBundle/Controller/CustomExceptionController.php
use Symfony\Component\Debug\Exception\FlattenException;    
//use Symfony\Component\HttpKernel\Exception\FlattenException;

class CustomExceptionController extends ExceptionController {   

protected $translator;

public function __construct(\Twig_Environment $twig, $debug, Translator $translator) {
    parent::__construct($twig, $debug);
    $this->translator = $translator;
}

public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null) {
    ...
}

The only change in the config of the CustomExceptionController is using

use Symfony\Component\Debug\Exception\FlattenException 

instead of

use Symfony\Component\HttpKernel\Exception\FlattenException

(which is deprecated since Symfony 2.3). However the problem is the same, also when this changed back to the ..\HttpKernel\... class.

As far as I can tell there have been no other changes the the configuration of the CustomExceptionController. The config is exactly the same as in the Symfony docs.

Any idea what might be wrong?

来源:https://stackoverflow.com/questions/39853878/customy-exception-control-not-working-anymore-after-update-to-symfony-2-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!