问题
I'm trying to develop a dashboard with the SonataAdminBundle, which displays some entities depending on the role of the user.
For instance, if the connected user has the ROLE_SUPER_ADMIN
, all entities should be shown. But if the user is ROLE_USER
, only a determinated entity should be shown, not all of them.
Is it possible do it in the service declaration of the entity?
回答1:
for future reference the trick is to use createQuery and permanentParamters in Sonata to be able to enforce filters. I have just written an article about that: http://www.theodo.fr/blog/2016/09/sonata-for-symfony-hide-your-filters/
来源:https://stackoverflow.com/questions/15878789/sonata-admin-bundle-filter-show-entity-from-role-user