fix sf4 deprecated: improve relying AuthorizationHelper service

This commit is contained in:
Tchama 2020-07-23 12:51:07 +02:00
parent 61c11c3eee
commit c5b1caefb6
2 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,7 @@ namespace Chill\DocStoreBundle\Controller;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\DocStoreBundle\Form\PersonDocumentType;
use Chill\DocStoreBundle\Repository\DocumentRepository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -36,16 +37,23 @@ class DocumentPersonController extends Controller
*/
protected $eventDispatcher;
/**
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
* DocumentPersonController constructor.
*
* @param TranslatorInterface $translator
* @param EventDispatcherInterface $eventDispatcher
* @param AuthorizationHelper $authorizationHelper
*/
public function __construct(TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher)
public function __construct(TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper)
{
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
}
/**
@ -61,7 +69,7 @@ class DocumentPersonController extends Controller
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$reachableScopes = $this->get('chill.main.security.authorization.helper')
$reachableScopes = $this->authorizationHelper
->getReachableScopes(
$this->getUser(), new Role(PersonDocumentVoter::SEE),
$person->getCenter());

View File

@ -5,5 +5,7 @@ services:
Chill\DocStoreBundle\Controller\DocumentPersonController:
autowire: true
public: true # TODO sf4, check if service could be public
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'