src/Security/IsNotEmployeeVoter.php line 11

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Security;
  4. use App\Entity\System\Employee;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class IsNotEmployeeVoter extends Voter
  8. {
  9.     public const IS_NOT_EMPLOYEE 'IS_NOT_EMPLOYEE';
  10.     protected function supports($attribute$subject): bool
  11.     {
  12.         return $attribute === self::IS_NOT_EMPLOYEE;
  13.     }
  14.     protected function voteOnAttribute($attribute$subjectTokenInterface $token): bool
  15.     {
  16.         $user $token->getUser();
  17.         return !($user instanceof Employee);
  18.     }
  19. }