简体   繁体   中英

Sonata Admin Bundle filter show entity from role user

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?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM