@@ -251,7 +251,56 @@ will be passed two parameters:
251
251
Instead of creating a new exception controller from scratch you can, of course,
252
252
also extend the default :class: `Symfony\\ Bundle\\ TwigBundle\\ Controller\\ ExceptionController `.
253
253
In that case, you might want to override one or both of the ``showAction() `` and
254
- ``findTemplate() `` methods. The latter one locates the template to be used.
254
+ ``findTemplate() `` methods. The latter one locates the template to be used.
255
+
256
+ .. note ::
257
+
258
+ In case of extending the
259
+ :class: `Symfony\\ Bundle\\ TwigBundle\\ Controller\\ ExceptionController ` you
260
+ may configure a service to pass the Twig environment and the ``debug `` flag
261
+ to the constructor.
262
+
263
+ .. configuration-block ::
264
+
265
+ .. code-block :: yaml
266
+
267
+ # app/config/services.yml
268
+ services :
269
+ app.exception_controller :
270
+ class : AppBundle\CustomExceptionController
271
+ arguments : ['@twig', '%kernel.debug%']
272
+
273
+ .. code-block :: xml
274
+
275
+ <!-- app/config/services.xml -->
276
+ <?xml version =" 1.0" encoding =" utf-8" ?>
277
+ <container xmlns =" http://symfony.com/schema/dic/services"
278
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
279
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
280
+ >
281
+ <services >
282
+ <service id =" app.exception_controller"
283
+ class =" AppBundle\Controller\CustomExceptionController"
284
+ >
285
+ <argument type =" service" id =" twig" />
286
+ <argument >%kernel.debug%</argument >
287
+ </service >
288
+ </services >
289
+ </container >
290
+
291
+ .. code-block :: php
292
+
293
+ // app/config/services.php
294
+ use Symfony\Component\DependencyInjection\Reference;
295
+ use Symfony\Component\DependencyInjection\Definition;
296
+
297
+ $definition = new Definition('AppBundle\Controller\CustomExceptionController', array(
298
+ new Reference('twig'),
299
+ '%kernel.debug%'
300
+ ));
301
+
302
+ And then configure ``twig.exception_controller `` using the controller as
303
+ services syntax (e.g. ``app.exception_controller:showAction ``).
255
304
256
305
.. tip ::
257
306
0 commit comments