mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
add a button 'new task' in page head and improve voter
This commit is contained in:
@@ -27,6 +27,7 @@ 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\Person;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -77,8 +78,9 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf
|
||||
|
||||
public function supports($attribute, $subject)
|
||||
{
|
||||
return $subject instanceof AbstractTask
|
||||
&& in_array($attribute, self::ROLES);
|
||||
return ($subject instanceof AbstractTask && in_array($attribute, self::ROLES))
|
||||
||
|
||||
($subject instanceof Person && $attribute === self::CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,12 +98,18 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($subject->getPerson() === null) {
|
||||
throw new \LogicException("You should associate a person with task "
|
||||
. "in order to check autorizations");
|
||||
if ($subject instanceof AbstractTask) {
|
||||
if ($subject->getPerson() === null) {
|
||||
throw new \LogicException("You should associate a person with task "
|
||||
. "in order to check autorizations");
|
||||
}
|
||||
|
||||
$person = $subject->getPerson();
|
||||
} else {
|
||||
$person = $subject;
|
||||
}
|
||||
|
||||
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $subject->getPerson())) {
|
||||
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user