Closed AntoineRoue closed 3 years ago
Hi, can you provide a PR to update the doc ?
Instead of extending the class, you need to create your own handler, implementing https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Security/Handler/SecurityHandlerInterface.php
I think you can use service decoration https://symfony.com/doc/current/service_container/service_decoration.html but you can also just copy the logic you need and override the logic you want to change
I'll try your suggestions and update the doc. If I create my own handler implementing SecurityHandlerInterface, how is it going to be called instead of RoleSecurityHandler ?
You can override the admin config to use your own securityHandler by following https://docs.sonata-project.org/projects/SonataAdminBundle/en/4.x/cookbook/recipe_overwrite_admin_configuration/#overwrite-admin-configuration
with the key security_handler
Ok. I'll explain this way in the doc then, I think it is a bit simpler than with a decorator. Also, the documentation says "If you want to change the handler behavior (for example, to pass the current object to voters)". The example does not make sense because the current object is already passed to voters. So I'll also remove it.
Hello,
I just noticed today that the Security documentation says that "If you want to change the handler behavior, extend Sonata\AdminBundle\Security\Handler\RoleSecurityHandler, and override the isGranted method." However, this class is final in 4.x and marked final since sonata-project/admin-bundle 3.52 in 3.x. So it is impossible.