Add IsGranted to AnnotationController

This commit is contained in:
Yassine Guedidi
2025-03-10 23:05:06 +01:00
parent b9900c311d
commit 61e2cb37df
8 changed files with 173 additions and 24 deletions

View File

@ -17,6 +17,8 @@ class EntryVoter extends Voter
public const SHARE = 'SHARE';
public const UNSHARE = 'UNSHARE';
public const DELETE = 'DELETE';
public const LIST_ANNOTATIONS = 'LIST_ANNOTATIONS';
public const CREATE_ANNOTATIONS = 'CREATE_ANNOTATIONS';
protected function supports(string $attribute, $subject): bool
{
@ -24,7 +26,7 @@ class EntryVoter extends Voter
return false;
}
if (!\in_array($attribute, [self::VIEW, self::EDIT, self::RELOAD, self::STAR, self::ARCHIVE, self::SHARE, self::UNSHARE, self::DELETE], true)) {
if (!\in_array($attribute, [self::VIEW, self::EDIT, self::RELOAD, self::STAR, self::ARCHIVE, self::SHARE, self::UNSHARE, self::DELETE, self::LIST_ANNOTATIONS, self::CREATE_ANNOTATIONS], true)) {
return false;
}
@ -50,6 +52,8 @@ class EntryVoter extends Voter
case self::SHARE:
case self::UNSHARE:
case self::DELETE:
case self::LIST_ANNOTATIONS:
case self::CREATE_ANNOTATIONS:
return $user === $subject->getUser();
}