I'm using SonataAdmin with sonata.admin.security.handler.role (so I don't use ACLs here).
I'm trying to restrict access to an object with a custom voter.
service
security.access.company_voter:
class: Application\...\Voter\CompanyVoter
public: false
tags:
- { name: security.voter }
voter Application...\Voter\CompanyVoter.php
#...
public function vote(TokenInterface $token, $object, array $attributes)
{
get_class($object);
}
#...
But I'm always getting an instance of Application\...\Voter\CompanyVoter instead of the expected object to restrict.
What can be the reason ?
Are you telling me that Sonata does not pass the object to isGranted() when using the role security handler ?
is_granted(). Specifically I need to restrict the access to user edition. - Pierre de LESPINAYSymfony\Component\HttpFoundation\Requestinstead of his object's FQCN. Did you manage to solve this issue meanwhile? - Nicolai Fröhlich