@@ -273,7 +273,56 @@ will be passed two parameters:
273273Instead of creating a new exception controller from scratch you can, of course,
274274also extend the default :class: `Symfony\\ Bundle\\ TwigBundle\\ Controller\\ ExceptionController `.
275275In that case, you might want to override one or both of the ``showAction() `` and
276- ``findTemplate() `` methods. The latter one locates the template to be used.
276+ ``findTemplate() `` methods. The latter one locates the template to be used.
277+
278+ .. note ::
279+
280+ In case of extending the
281+ :class: `Symfony\\ Bundle\\ TwigBundle\\ Controller\\ ExceptionController ` you
282+ may configure a service to pass the Twig environment and the ``debug `` flag
283+ to the constructor.
284+
285+ .. configuration-block ::
286+
287+ .. code-block :: yaml
288+
289+ # app/config/services.yml
290+ services :
291+ app.exception_controller :
292+ class : AppBundle\CustomExceptionController
293+ arguments : ['@twig', '%kernel.debug%']
294+
295+ .. code-block :: xml
296+
297+ <!-- app/config/services.xml -->
298+ <?xml version =" 1.0" encoding =" utf-8" ?>
299+ <container xmlns =" http://symfony.com/schema/dic/services"
300+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
301+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
302+ >
303+ <services >
304+ <service id =" app.exception_controller"
305+ class =" AppBundle\Controller\CustomExceptionController"
306+ >
307+ <argument type =" service" id =" twig" />
308+ <argument >%kernel.debug%</argument >
309+ </service >
310+ </services >
311+ </container >
312+
313+ .. code-block :: php
314+
315+ // app/config/services.php
316+ use Symfony\Component\DependencyInjection\Reference;
317+ use Symfony\Component\DependencyInjection\Definition;
318+
319+ $definition = new Definition('AppBundle\Controller\CustomExceptionController', array(
320+ new Reference('twig'),
321+ '%kernel.debug%'
322+ ));
323+
324+ And then configure ``twig.exception_controller `` using the controller as
325+ services syntax (e.g. ``app.exception_controller:showAction ``).
277326
278327.. tip ::
279328
0 commit comments