mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 13:33:48 +00:00
wip.. adapt EventVoter to sf3
This commit is contained in:
@@ -2,21 +2,15 @@
|
||||
|
||||
namespace Chill\EventBundle\Menu;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\EventBundle\Security\Authorization\EventVoter;
|
||||
|
||||
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var TokenStorageInterface
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -26,18 +20,16 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
/**
|
||||
*
|
||||
* @var AuthorizationHelper
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
protected $authorizationHelper;
|
||||
protected $authorizationChecker;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
AuthorizationCheckerInterface $authorizationChecker,
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->authorizationChecker = $authorizationChecker;
|
||||
$this->translator = $translator;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +38,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $parameters['person'];
|
||||
|
||||
$user = $this->tokenStorage->getToken()->getUser();
|
||||
$roleSee = new Role(EventVoter::SEE);
|
||||
|
||||
// ASK use authorizationHelper or authorizationChecker ??
|
||||
if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) {
|
||||
if ($this->authorizationChecker->isGranted(EventVoter::SEE, $person)) {
|
||||
|
||||
$menu->addChild($this->translator->trans('Events participation'), [
|
||||
'route' => 'chill_event__list_by_person',
|
||||
|
Reference in New Issue
Block a user