Sonata Admin Bundle filter show entity from role user

倖福魔咒の 提交于 2019-12-13 07:42:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!