private function getUrlPattern(Router $router, $routeNameFromMappingFile, $baseUrl)
{
if (!empty($routeNameFromMappingFile)) {
try {
$route = $router->getRouteCollection()->get($routeNameFromMappingFile);
if (empty($route)) {
throw new Exception();
}
} catch (Exception $e) {
throw new RuntimeException(\sprintf('Route \'%s\' has not been defined as a Symfony route.', $routeNameFromMappingFile));
}
\preg_match_all('/{(.*?)}/', $route->getPath(), $matches);
$pattern = [];
if (!empty($matches)) {
$pattern = \array_combine($matches[1], $matches[0]);
}
return $baseUrl . \urldecode($router->generate($routeNameFromMappingFile, $pattern, true));
}
return (string) $routeNameFromMappingFile;
}