Description
Description
Add a route path (URL pattern) to the returned URL matcher parameters. Currently, UrlMatcher returns an array (example from demo app):
[
"_route" => "blog_index",
"page" => "1",
"_format" => "html",
"_controller" => "App\Controller\BlogController::index",
"_locale" => "fr"
]
But sometimes the route pattern is needed (like /{_locale}/blog/
).
Example
The real use case is: my client wants the integration of a site monitoring system with Symfony, and wants to group information of each request by URL patterns. Currently, there's no other way to get route path pattern except using Router::getRouteCollection()
which is not recommended. Also, Router::match()
leads to Twig related exception in the demo app:
An exception has been thrown during the rendering of a template ("No routes found for "/_fragment/".").
To reproduce a Twig exception, you need to set up a demo app, create an event listener that is executed before RouterListener (e.g. priority 9999), inject Router, and execute $this->router->match($request->getPathInfo());
on kernel.request
event