fix sf4 deprecated: improve relying AuthorizationHelper service

This commit is contained in:
Tchama 2020-07-23 12:51:07 +02:00
parent 5f8037433d
commit 3d1a12dc8b
2 changed files with 11 additions and 2 deletions

View File

@ -22,6 +22,7 @@
namespace Chill\ActivityBundle\Controller; namespace Chill\ActivityBundle\Controller;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -44,14 +45,21 @@ class ActivityController extends Controller
*/ */
protected $eventDispatcher; protected $eventDispatcher;
/**
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/** /**
* ActivityController constructor. * ActivityController constructor.
* *
* @param EventDispatcherInterface $eventDispatcher * @param EventDispatcherInterface $eventDispatcher
* @param AuthorizationHelper $authorizationHelper
*/ */
public function __construct(EventDispatcherInterface $eventDispatcher) public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper)
{ {
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
} }
/** /**
@ -69,7 +77,7 @@ class ActivityController extends Controller
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); $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'), ->getReachableScopes($this->getUser(), new Role('CHILL_ACTIVITY_SEE'),
$person->getCenter()); $person->getCenter());

View File

@ -2,4 +2,5 @@ services:
Chill\ActivityBundle\Controller\ActivityController: Chill\ActivityBundle\Controller\ActivityController:
arguments: arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
tags: ['controller.service_arguments'] tags: ['controller.service_arguments']