From 3d1a12dc8be954f6cfd6cb8d3c1ca6d33e6ce4d2 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 23 Jul 2020 12:51:07 +0200 Subject: [PATCH] fix sf4 deprecated: improve relying AuthorizationHelper service --- Controller/ActivityController.php | 12 ++++++++++-- Resources/config/services/controller.yml | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Controller/ActivityController.php b/Controller/ActivityController.php index 8e6c25e76..8e3ff7958 100644 --- a/Controller/ActivityController.php +++ b/Controller/ActivityController.php @@ -22,6 +22,7 @@ namespace Chill\ActivityBundle\Controller; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -44,14 +45,21 @@ class ActivityController extends Controller */ protected $eventDispatcher; + /** + * @var AuthorizationHelper + */ + protected $authorizationHelper; + /** * ActivityController constructor. * * @param EventDispatcherInterface $eventDispatcher + * @param AuthorizationHelper $authorizationHelper */ - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) { $this->eventDispatcher = $eventDispatcher; + $this->authorizationHelper = $authorizationHelper; } /** @@ -69,7 +77,7 @@ class ActivityController extends Controller $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $reachableScopes = $this->get('chill.main.security.authorization.helper') + $reachableScopes = $this->authorizationHelper ->getReachableScopes($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), $person->getCenter()); diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 075c52679..a1930760b 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -2,4 +2,5 @@ services: Chill\ActivityBundle\Controller\ActivityController: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' tags: ['controller.service_arguments']