in vendor/symfony/symfony/src/Symfony/Component/Routing/Router.php
It is possible to replace matcher_class , which should be possible in config.yml .
If you are a subclass of UrlMatcher and overRide matchRequest , which will take precedence over path matching (URL only).
matchRequest accepts the parameter $ request (request object)
The Request object should contain the user information provided to the security listener before starting the receiver of the router and allow you to choose the route by combining the URL and the user role. Routes are stored in an array indexed by name, so the names must be different.
You could use names like post_index[USER] post_index[STAFF] post_index[MODERATOR]
To generate URLs using {{ path('post_index', {...}) }} , you will also need to replace the URLGenerator subclass and insert it into the router using the generator_class option.
Jason hendry
source share