wip.. EVENT_SEE and _CREATE works in twig test, not in php test

This commit is contained in:
2019-01-25 15:39:44 +01:00
parent 2d295d8e43
commit 31876ee8b6
3 changed files with 24 additions and 11 deletions

View File

@@ -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;
}