From 31876ee8b6200027e1456ae7639de52695f55346 Mon Sep 17 00:00:00 2001 From: Tchama Date: Fri, 25 Jan 2019 15:39:44 +0100 Subject: [PATCH] wip.. EVENT_SEE and _CREATE works in twig test, not in php test --- Menu/PersonMenuBuilder.php | 13 +++++++++++-- Resources/views/Event/listByPerson.html.twig | 7 +++++++ Security/Authorization/EventVoter.php | 15 ++++++--------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php index 130622c2c..7411d482b 100644 --- a/Menu/PersonMenuBuilder.php +++ b/Menu/PersonMenuBuilder.php @@ -4,7 +4,6 @@ namespace Chill\EventBundle\Menu; 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\EventBundle\Security\Authorization\EventVoter; @@ -36,7 +35,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { /* @var $person \Chill\PersonBundle\Entity\Person */ - $person = $parameters['person']; + $person = $parameters['person'] ?? null; if ($this->authorizationChecker->isGranted(EventVoter::SEE, $person)) { @@ -49,7 +48,17 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface ->setExtras([ 'order' => 500 ]); + } + //// + else { + dump('not see'); } + if ($this->authorizationChecker->isGranted(EventVoter::CREATE, $person)) { + dump('create'); + } else { + dump('not create'); + } + //// } public static function getMenuIds(): array diff --git a/Resources/views/Event/listByPerson.html.twig b/Resources/views/Event/listByPerson.html.twig index f0337b300..82742674f 100644 --- a/Resources/views/Event/listByPerson.html.twig +++ b/Resources/views/Event/listByPerson.html.twig @@ -50,6 +50,13 @@