fix sf4 deprecated: improve relying AuthorizationHelper service

This commit is contained in:
Tchama 2020-07-23 12:51:07 +02:00
parent 137294d8b8
commit a812a0c132
2 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@
namespace Chill\ReportBundle\Controller;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
@ -45,14 +46,21 @@ class ReportController extends Controller
*/
protected $eventDispatcher;
/**
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
* ReportController 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;
}
@ -71,7 +79,7 @@ class ReportController 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_REPORT_SEE'),
$person->getCenter());

View File

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