public function getRouteCollectionForRequest(Request
$request) { // Cache both the system path as well as route parameters and matching
// routes.
$cid =
$this->
getRouteCollectionCacheId($request);
if ($cached =
$this->cache->
get($cid)) { $this->currentPath->
setPath($cached->data
['path'
],
$request);
$request->query->
replace($cached->data
['query'
]);
return $cached->data
['routes'
];
} else { // Just trim on the right side.
$path =
$request->
getPathInfo();
$path =
$path === '/' ?
$path :
rtrim($request->
getPathInfo(), '/'
);
$path =
$this->pathProcessor->
processInbound($path,
$request);
$this->currentPath->
setPath($path,
$request);