mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
Merge remote-tracking branch 'origin/master' into issue534_bulk_reassign
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Security\Authorization;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class AccompanyingPeriodCommentVoter extends Voter
|
||||
@@ -22,6 +23,13 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
|
||||
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT';
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
return $subject instanceof Comment;
|
||||
@@ -32,8 +40,10 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
/** @var Comment $subject */
|
||||
switch ($attribute) {
|
||||
case self::EDIT:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
case self::DELETE:
|
||||
return $subject->getCreator() === $token->getUser();
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("This attribute {$attribute} is not supported");
|
||||
|
Reference in New Issue
Block a user