if ($request->attributes->
has('_controller'
)) { // routing is already done
return;
} // add attributes based on the request (routing)
try { // matching a request is more powerful than matching a URL path + context, so try that first
if ($this->matcher instanceof RequestMatcherInterface
) { $parameters =
$this->matcher->
matchRequest($request);
} else { $parameters =
$this->matcher->
match($request->
getPathInfo());
} $this->logger?->
info('Matched route "{route}".',
[ 'route' =>
$parameters['_route'
] ?? 'n/a',
'route_parameters' =>
$parameters,
'request_uri' =>
$request->
getUri(),
'method' =>
$request->
getMethod(),
]);
$request->attributes->
add($parameters);
unset($parameters['_route'
],
$parameters['_controller'
]);