Angel
Angel

Reputation: 1980

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?

Upvotes: 0

Views: 988

Answers (1)

vicdup
vicdup

Reputation: 171

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/

Upvotes: 0

Related Questions