function CompiledUrlMatcherDumper::compileStaticRoutes
Compiles static routes in a switch statement.
Condition-less paths are put in a static array in the switch's default, with generic matching logic. Paths that can match two or more routes, or have user-specified conditions are put in separate switch's cases.
Throws
\LogicException
1 call to CompiledUrlMatcherDumper::compileStaticRoutes()
- CompiledUrlMatcherDumper::getCompiledRoutes in vendor/
symfony/ routing/ Matcher/ Dumper/ CompiledUrlMatcherDumper.php - Generates the arrays for CompiledUrlMatcher's constructor.
File
-
vendor/
symfony/ routing/ Matcher/ Dumper/ CompiledUrlMatcherDumper.php, line 212
Class
- CompiledUrlMatcherDumper
- CompiledUrlMatcherDumper creates PHP arrays to be used with CompiledUrlMatcher.
Namespace
Symfony\Component\Routing\Matcher\DumperCode
private function compileStaticRoutes(array $staticRoutes, array &$conditions) : array {
if (!$staticRoutes) {
return [];
}
$compiledRoutes = [];
foreach ($staticRoutes as $url => $routes) {
$compiledRoutes[$url] = [];
foreach ($routes as $name => [
$route,
$hasTrailingSlash,
]) {
$compiledRoutes[$url][] = $this->compileRoute($route, $name, (!$route->compile()
->getHostVariables() ? $route->getHost() : $route->compile()
->getHostRegex()) ?: null, $hasTrailingSlash, false, $conditions);
}
}
return $compiledRoutes;
}