Suppose in my system there are four user roles-
1. ROLE_SUPER_ADMIN
2. ROLE_ADMIN
3. ROLE_EDITOR
4. ROLE_AUTHOR
Now think, a user has role ROLE_AUTHOR. He can access a specific document but none other user can access it. So I want permit only user who has ROLE_AUTHOR
. I got some solution when searching which has like
is_granted('ROLE_AUTHOR')
but this return a hierarchical result. Because in my config file I set hierarchy.
So how can I give permission only ROLE_AUTHOR
user.
You could check the user has the role exactly.
In twig:
In controller: