src/Security/Voter/CuratorCommentaryHWRVoter.php line 11

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Security\Voter;
  4. use App\Service\CommentaryService;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class CuratorCommentaryHWRVoter extends Voter
  8. {
  9.     public const CURATOR_SEE_HWR 'CURATOR_SEE_HWR';
  10.     private CommentaryService $commentaryService;
  11.     public function __construct(CommentaryService $commentaryService)
  12.     {
  13.         $this->commentaryService $commentaryService;
  14.     }
  15.     protected function supports($attribute$commentaryId): bool
  16.     {
  17.         return $attribute === self::CURATOR_SEE_HWR
  18.             && is_int($commentaryId);
  19.     }
  20.     protected function voteOnAttribute($attribute$commentaryIdTokenInterface $token): bool
  21.     {
  22.         return $this->commentaryService->handleCuratorCommentaryAccess($commentaryId$token->getUser());
  23.     }
  24. }