From 7cef9f338592859b524fba23518dbc0734407c65 Mon Sep 17 00:00:00 2001 From: Brad Mostert Date: Thu, 11 Oct 2018 23:07:44 +0200 Subject: [PATCH] Replace usage of deprecated security.context with security.authorization_checker --- Resources/doc/expressions.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Resources/doc/expressions.rst b/Resources/doc/expressions.rst index 8cb862a..8c4519f 100644 --- a/Resources/doc/expressions.rst +++ b/Resources/doc/expressions.rst @@ -23,10 +23,13 @@ of the SecurityContext. Some examples: use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression; - $securityContext->isGranted(array(new Expression('hasRole("A")'))); - $securityContext->isGranted(array(new Expression('hasRole("A") or (hasRole("B") and hasRole("C"))'))); - $securityContext->isGranted(array(new Expression('hasPermission(object, "VIEW")')), $object); - $securityContext->isGranted(array(new Expression('token.getUsername() == "Johannes"'))); + $authorizationChecker = $this->get('security.authorization_checker'); + // Prior to Symfony 2.6 use 'security.context' instead of 'security.authorization_checker' + + $authorizationChecker->isGranted(array(new Expression('hasRole("A")'))); + $authorizationChecker->isGranted(array(new Expression('hasRole("A") or (hasRole("B") and hasRole("C"))'))); + $authorizationChecker->isGranted(array(new Expression('hasPermission(object, "VIEW")')), $object); + $authorizationChecker->isGranted(array(new Expression('token.getUsername() == "Johannes"'))); Twig Usage ~~~~~~~~~~