While testing roles in my application I found the function isGranted
of the SecurityContext
. It works great but now I need to check the roles of a user that is not the current user so isGranted
doesn't work for me.
I've been looking and I found the function hasRole
of the user, the problem is that this function doesn't look in the hierarchy tree of Symfony and it just looks in the roles assigned to the user.
So, Is there a function that looks for a role of a user looking in the hierarchy tree like isGranted
do for the current user?
EDIT
I found this solution:
How to use the AccessDecisionManager in Symfony2 for authorization of arbitrary users?
I implemented it and it works, the problem is that it needs the ContainerBuilder
and I would prefer a different approach.
Any Idea?