<?php
declare(strict_types=1);
namespace App\Security;
use App\Entity\System\Employee;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class IsNotEmployeeVoter extends Voter
{
public const IS_NOT_EMPLOYEE = 'IS_NOT_EMPLOYEE';
protected function supports($attribute, $subject): bool
{
return $attribute === self::IS_NOT_EMPLOYEE;
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
$user = $token->getUser();
return !($user instanceof Employee);
}
}