mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
wip.. EVENT_SEE and _CREATE works in twig test, not in php test
This commit is contained in:
parent
2d295d8e43
commit
31876ee8b6
@ -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)) {
|
||||
|
||||
@ -50,6 +49,16 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
'order' => 500
|
||||
]);
|
||||
}
|
||||
////
|
||||
else {
|
||||
dump('not see');
|
||||
}
|
||||
if ($this->authorizationChecker->isGranted(EventVoter::CREATE, $person)) {
|
||||
dump('create');
|
||||
} else {
|
||||
dump('not create');
|
||||
}
|
||||
////
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
|
@ -50,6 +50,13 @@
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
{% if is_granted('CHILL_EVENT_SEE', participation.event) %}
|
||||
see {% else %} not see
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_EVENT_CREATE', participation.event) %}
|
||||
create {% else %} not create
|
||||
{% endif %}
|
||||
|
||||
{% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %}
|
||||
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button black">
|
||||
{{ 'See'|trans }}
|
||||
|
@ -87,18 +87,15 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
|
||||
}
|
||||
|
||||
if ($subject instanceof Event) {
|
||||
if ($subject->getId() === null) {
|
||||
throw new \LogicException("You should associate a person with event "
|
||||
. "in order to check autorizations");
|
||||
}
|
||||
$person = $subject->getId(); // liaison event --> person
|
||||
return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||
|
||||
} elseif ($subject instanceof Person) {
|
||||
$person = $subject;
|
||||
return $this->authorizationHelper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||
|
||||
} else {
|
||||
// subject is null. We check that at least one center is reachable
|
||||
$centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute));
|
||||
$centers = $this->authorizationHelper
|
||||
->getReachableCenters($token->getUser(), new Role($attribute));
|
||||
|
||||
return count($centers) > 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user