src/Evo/Application/Security/Voter/AdminManageVoter.php line 10

Open in your IDE?
  1. <?php
  2. namespace Evo\Application\Security\Voter;
  3. use Evo\Application\Security\Permissions;
  4. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  5. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  6. use Symfony\Component\Security\Core\Security;
  7. class AdminManageVoter extends Voter
  8. {
  9.     private const SUPPORTED_ATTRIBUTES = [
  10.         Permissions::ADMIN_MANAGE_INVOICES,
  11.     ];
  12.     private Security $security;
  13.     public function __construct(Security $security)
  14.     {
  15.         $this->security $security;
  16.     }
  17.     protected function supports(string $attribute$subject): bool
  18.     {
  19.         return \in_array($attributeself::SUPPORTED_ATTRIBUTEStrue);
  20.     }
  21.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  22.     {
  23.         return $this->security->isGranted('ROLE_ADMIN');
  24.     }
  25. }