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