I try to override Exception Controller with Symfony 3 I followed their example here http://symfony.com/doc/current/controller/error_pages.html but it doesn't work
So first I have created my error page in app/Ressources/TwigBundle.../error404.html.twig
And it works without the controller overriding.
Second, I have added in services.yml, under services:
frontBundle\Controller\CustomExceptionController:
public: true
arguments:
$debug: '%kernel.debug%'
Third in my Controller folder, I have created a CustomExceptionController.php Inside, I have put (I want to override findtemple() for example)
namespace frontBundle\Controller;
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Component\HttpFoundation\Request;
class CustomExceptionController extends ExceptionController
{
/**
* @param Request $request
* @param string $format
* @param int $code An HTTP response status code
* @param bool $showException
*
* @return TemplateReferenceInterface
*/
protected function findTemplate(Request $request, $format, $code,
$showException)
{
}
}
However it doesn't work. This new controller is not taken into consideration and the findTemplate() is not overrided.
Did I miss something?
There are really not a lot of help about that with Symfony 3...
Thank you so much
exception_controllersetting inside yourconfig.yml(as stated in your link)?frontBundle:CustomException:showif you extend the default exception controller. (Since your controller is calledCustomExceptionControllerand the inherited method is calledshowAction)