src/Security/Voter/TagVoter.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Security\Voter;
  3. use App\Entity\Tag;
  4. use App\Utils\VoterHelper;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class TagVoter extends Voter
  8. {
  9.     private const SEE    'see';
  10.     private const EDIT   'edit';
  11.     private const DELETE 'delete';
  12.     /**
  13.      * TagVoter constructor.
  14.      */
  15.     public function __construct()
  16.     {
  17.     }
  18.     protected function supports(string $attributemixed $subject): bool
  19.     {
  20.         return $subject instanceof Tag && in_array($attribute, [self::SEEself::EDITself::DELETE], true);
  21.     }
  22.     protected function voteOnAttribute(string $attributemixed $subjectTokenInterface $token): bool
  23.     {
  24.         return VoterHelper::voteOnAttribute($attribute$subject$token'tag');
  25.     }
  26. }