8000 [#7105] add XML and PHP service config examples · a-ast/symfony-docs@c698051 · GitHub
[go: up one dir, main page]

Skip to content

Commit c698051

Browse files
committed
[symfony#7105] add XML and PHP service config examples
1 parent 39481b3 commit c698051

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

security/access_denied_handler.rst

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,36 @@ generally return a custom response).
6767
6868
Then, register the service for the access denied handler:
6969

70-
.. code-block:: yaml
70+
.. configuration-block::
71+
72+
.. code-block:: yaml
73+
74+
# app/config/services.yml
75+
services:
76+
app.security.access_denied_handler:
77+
class: AppBundle\Security\AccessDeniedHandler
78+
79+
.. code-block:: xml
80+
81+
<!-- app/config/services.xml -->
82+
<?xml version="1.0" encoding="UTF-8" ?>
83+
<container xmlns="http://symfony.com/schema/dic/services"
84+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
85+
xsi:schemaLocation="http://symfony.com/schema/dic/services
86+
http://symf A211 ony.com/schema/dic/services/services-1.0.xsd">
87+
88+
<services>
89+
<service id="app.security.access_denied_handler"
90+
class="AppBundle\Security\AccessDeniedHandler" />
91+
</services>
92+
</container>
93+
94+
.. code-block:: php
7195
72-
# app/config/services.yml
73-
services:
74-
app.security.access_denied_handler:
75-
class: AppBundle\Security\AccessDeniedHandler
96+
// app/config/services.php
97+
$container->register(
98+
'app.security.access_denied_handler',
99+
'AppBundle\Security\AccessDeniedHandler'
100+
);
76101

77102
That's it! Any ``AccessDeniedException`` thrown by the ``foo`` firewall will now be handled by your service.

0 commit comments

Comments
 (0)
0