I have following setup:
dynamic routes loader which genrates routes and calls proper controller based on information from database about application views
custom security voter which verifies if user should have access to current view
I could of course call is_granted method from within proper controller and it works. What I would like to do though is to trigger voter not from within controller (which requires to repeat myself in every controller just with different view ID) but to triger it automatically for every route generated in routes loader. This way I would not have to perform standard verification which is basically the same for every route - check if user has access to this view but focus on business logic which may require additional requirement to fulfill for user to have access to this route (and this is what would be in controller).
I was going in direction that there is some parameter in route generation method:
$route = new Route($path, $defaults, $requirements);
$routes->add($routeName, $route);
which would allow me to trigger is_granted for created route but documentation about parameters is scarce.
Does anyone know how to pass this kind requirement to user eg. for created route require that user is_granted('VIEW_1')?