I have multiple user roles on my site. Some of the controllers have access restriction based on a user role.
I also have a menu (based on KnpMenuBundle), and I need include only items which are accessible for a logged-in user.
For now I've decided to filter items this way:
1. Add to all of the protected routes a new option roles
: i.e. roles: [ROLE_ADMIN, ROLE_MANAGER]
2. During menu building match current user roles with the option.
I've tried to find out whether is there such a functionality in Symfony (I mean role restriction defined in route settings), but I failed to find something similar to that.
So the questions I have are:
1. How to filter menu items based on user roles? (May be is there already a functionality for that?)
If the answer for the previous question is "no", then:
2. how can I build such a filtering on my own? As I've already mentioned I've decided to add a new option in this case, so how to do it the best way?