Skip to content

Commit 51ffd21

Browse files
Cydonia7wouterj
authored andcommitted
Fixes
1 parent 5b015f2 commit 51ffd21

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

book/security.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -816,19 +816,13 @@ to users that have a specific role.
816816
Securing Controllers and other Code
817817
...................................
818818

819-
You can easily deny access from inside a controller:
820-
821-
.. versionadded:: 2.6
822-
The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6. Previously (and
823-
still now), you could check access directly and throw the ``AccessDeniedException`` as shown
824-
in the example below).
825-
826-
.. code-block:: php
819+
You can easily deny access from inside a controller::
827820

828821
// ...
829822

830823
public function helloAction($name)
831824
{
825+
// The second parameter is used to specify on what object the role is tested.
832826
$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page!');
833827

834828
// Old way :
@@ -839,6 +833,11 @@ You can easily deny access from inside a controller:
839833
// ...
840834
}
841835

836+
.. versionadded:: 2.6
837+
The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6. Previously (and
838+
still now), you could check access directly and throw the ``AccessDeniedException`` as shown
839+
in the example above).
840+
842841
In both cases, a special
843842
:class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`
844843
is thrown, which ultimately triggers a 403 HTTP response inside Symfony.

0 commit comments

Comments
 (0)