Skip to content

Commit

Permalink
Backporting some stuff from 2.7, that I think must have gotten merged…
Browse files Browse the repository at this point in the history
… only there by accident
  • Loading branch information
weaverryan committed Mar 14, 2015
1 parent ebca342 commit 66831a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ You can easily deny access from inside a controller::
$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page!');

// Old way :
// if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) {
// if (false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
// throw $this->createAccessDeniedException('Unable to access this page!');
// }

Expand All @@ -829,6 +829,10 @@ You can easily deny access from inside a controller::
still now), you could check access directly and throw the ``AccessDeniedException`` as shown
in the example above).

.. versionadded:: 2.6
The ``security.authorization_checker`` service was introduced in Symfony 2.6. Prior
to Symfony 2.6, you had to use the ``isGranted()`` method of the ``security.context`` service.

In both cases, a special
:class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`
is thrown, which ultimately triggers a 403 HTTP response inside Symfony.
Expand Down

0 comments on commit 66831a6

Please sign in to comment.