As you can see in the following links, the supportsClass & supportsAttribute methods aren't called when we call isGranted():
Does these methods being called in other places?
Why they are part of interface?
As you can see in the following links, the supportsClass & supportsAttribute methods aren't called when we call isGranted():
Does these methods being called in other places?
Why they are part of interface?
Sound like it's a normal behavior since the voter have to check for the class.
Here is a the solution to check the class :
function vote(TokenInterface $token, $object, array $attributes)
{
$user = $token->getUser();
//sometime the object is a class or a instance of Request
if($object instanceOf \Symfony\Component\HttpFoundation\Request ){
return VoterInterface::ACCESS_ABSTAIN;
}else{
$class = $object->getType();
if($class == 'Vendor\\MyBundle\\Entity\\MyEntity'){
return VoterInterface::ACCESS_GRANTED;
}
}
return VoterInterface::ACCESS_DENIED;
}