Skip to content

Commit 3b0ea60

Browse files
committed
[#6224] Add other formats and fix indentation
1 parent 9f9d586 commit 3b0ea60

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

cookbook/controller/error_pages.rst

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,52 @@ In that case, you might want to override one or both of the ``showAction()`` and
221221

222222
.. note::
223223

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
224+
In case of extending the
225+
:class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController` you
226+
may configure a service to pass the Twig environment and the ``debug`` flag
227+
to the constructor.
228+
229+
.. configuration-block::
230+
231+
.. code-block:: yaml
232+
233+
# app/config/services.yml
234+
services:
235+
app.exception_controller:
236+
class: AppBundle\CustomExceptionController
237+
arguments: ['@twig', '%kernel.debug%']
238+
239+
.. code-bock:: xml
240+
241+
<!-- app/config/services.xml -->
242+
<?xml version="1.0" encoding="utf-8" ?>
243+
<container xmlns="http://symfony.com/schema/dic/services"
244+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
245+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
246+
>
247+
<services>
248+
<service id="app.exception_controller"
249+
class="AppBundle\Controller\CustomExceptionController"
250+
>
251+
<argument type="service" id="twig"/>
252+
<argument>%kernel.debug%</argument>
253+
</service>
254+
</services>
255+
</container>
256+
257+
.. code-block:: php
258+
259+
// app/config/services.php
260+
use Symfony\Component\DependencyInjection\Reference;
261+
use Symfony\Component\DependencyInjection\Definition;
262+
263+
$definition = new Definition('AppBundle\Controller\CustomExceptionController', array(
264+
new Reference('twig'),
265+
'%kernel.debug%'
266+
));
267+
268+
And then configure ``twig.exception_controller`` using the controller as
269+
services syntax (e.g. ``app.exception_controller:showAction``).
239270

240271
.. _use-kernel-exception-event:
241272

0 commit comments

Comments
 (0)