- I’ve created a User entity, which implements UserInterface. Everything it’s ok.
- I’ve created two auxiliar tables, managing roles and permissions (each role has some permissions).
So, my entities are:
User -> has one role (one role, and this role comes from—>)
Role -> just the name of the role
Permission -> just the name of the permission
RolePermission -> creates a relation between a role and permissions.
What I need to do is get the permissions the current logged user have: how to this? Looking first for the role of the user, and looking in RolePermission which permissions have.
This is ok, but once I have this permissions I need to send it to TWIG.
I can do this manually, sending on every $this->render of the app an array those permissions, but I think is not the best solution (lazy…).
Is possible to send this data (an array with the permissions) every time I render a TWIG template? How?
EDIT:
This question is about getting info associated with the logged user, but not about to check the role in TWIG (is_granted)
After lot of research, and because of my needs I’m finally returning and array with the permissions in every
->render