new/show/edit/delete/list functionality added for accompanyingperiod task

This commit is contained in:
2021-09-17 14:33:42 +02:00
parent 537518b66f
commit 6e3ce06fcf
15 changed files with 242 additions and 116 deletions

View File

@@ -32,7 +32,9 @@ use Psr\Log\LoggerInterface;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Chill\TaskBundle\Security\Authorization\AuthorizationEvent;
@@ -146,14 +148,15 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
/*
if ($subject instanceof AbstractTask) {
if ($subject->getPerson() === null) {
$associated = $subject->getPerson() ?? $subject->getCourse();
if ($associated === null) {
throw new \LogicException("You should associate a person with task "
. "in order to check autorizations");
}
$person = $subject->getPerson();
} elseif ($subject instanceof Person) {
$person = $subject;
$associated = $subject;
} else {
// subject is null. We check that at least one center is reachable
$centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute));
@@ -168,6 +171,8 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
if (NULL === $center) {
return false;
} elseif ($associated instanceof AccompanyingPeriod && !$this->accessDecisionManager->decide($token, [AccompanyingPeriodVoter::SEE], $associated)) {
return false;
}
return $this->authorizationHelper->userHasAccess(