Skip to content

Commit fff23f7

Browse files
pamuchewouterj
authored andcommitted
Note to create a service if you extend ExceptionController
1 parent d2c3e26 commit fff23f7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cookbook/controller/error_pages.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,25 @@ will be passed two parameters:
217217
Instead of creating a new exception controller from scratch you can, of course,
218218
also extend the default :class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`.
219219
In that case, you might want to override one or both of the ``showAction()`` and
220-
``findTemplate()`` methods. The latter one locates the template to be used.
220+
``findTemplate()`` methods. The latter one locates the template to be used.
221+
222+
.. note::
223+
224+
In case of extending the :class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`
225+
you may configure a service to pass the Twig environment and the ``debug`` flag to the constructor.
226+
227+
.. configuration-block::
228+
229+
.. code-block:: yaml
230+
231+
# app/config/config.yml
232+
services:
233+
app.extension_controller:
234+
class: AppBundle\CustomExceptionController
235+
arguments: [ "@twig", "%kernel.debug%" ]
236+
237+
twig:
238+
exception_controller: app.extension_controller:showAction
221239
222240
.. _use-kernel-exception-event:
223241

0 commit comments

Comments
 (0)