From 66831a698df427fafaa04fd9f8847a45ddce4b15 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 14 Mar 2015 14:53:58 -0400 Subject: [PATCH] Backporting some stuff from 2.7, that I think must have gotten merged only there by accident --- book/security.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/book/security.rst b/book/security.rst index f96a277c256..59460ec4067 100644 --- a/book/security.rst +++ b/book/security.rst @@ -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!'); // } @@ -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.