Skip to content

Commit

Permalink
minor #6224 Note to create a service if you extend ExceptionControlle…
Browse files Browse the repository at this point in the history
…r (pamuche)

This PR was submitted for the 3.0 branch but it was merged into the 2.3 branch instead (closes #6224).

Discussion
----------

Note to create a service if you extend ExceptionController

I had some trouble to get the custom exception handling with inheritance of ExceptionController working, because I hadn't a clue to make a service out of the ExceptionController of the TwigBundle.

Commits
-------

fff23f7 Note to create a service if you extend ExceptionController
  • Loading branch information
wouterj committed Feb 6, 2016
2 parents d2c3e26 + fff23f7 commit 9f9d586
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cookbook/controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,25 @@ will be passed two parameters:
Instead of creating a new exception controller from scratch you can, of course,
also extend the default :class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`.
In that case, you might want to override one or both of the ``showAction()`` and
``findTemplate()`` methods. The latter one locates the template to be used.
``findTemplate()`` methods. The latter one locates the template to be used.

.. note::

In case of extending the :class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`
you may configure a service to pass the Twig environment and the ``debug`` flag to the constructor.

.. configuration-block::

.. code-block:: yaml
# app/config/config.yml
services:
app.extension_controller:
class: AppBundle\CustomExceptionController
arguments: [ "@twig", "%kernel.debug%" ]
twig:
exception_controller: app.extension_controller:showAction
.. _use-kernel-exception-event:

Expand Down

0 comments on commit 9f9d586

Please sign in to comment.