<?php
namespace Aqarmap\Bundle\UserBundle\Security\Authorization\Voter;
use Aqarmap\Bundle\UserBundle\Constant\UserTypes;
use Aqarmap\Bundle\UserBundle\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class NonIndividualVoter extends Voter
{
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
if (UserTypes::INDIVIDUAL === $subject->getUserType()) {
return false;
}
return true;
}
public function supports($attribute, $subject): bool
{
return 'NON_INDIVIDUAL' === $attribute && $subject instanceof User;
}
}