function CompiledUrlMatcherDumper::compileRoute
Compiles a single Route to PHP code used to match it against the path info.
2 calls to CompiledUrlMatcherDumper::compileRoute()
- CompiledUrlMatcherDumper::compileStaticPrefixCollection in vendor/
symfony/ routing/ Matcher/ Dumper/ CompiledUrlMatcherDumper.php - Compiles a regexp tree of subpatterns that matches nested same-prefix routes.
- CompiledUrlMatcherDumper::compileStaticRoutes in vendor/
symfony/ routing/ Matcher/ Dumper/ CompiledUrlMatcherDumper.php - Compiles static routes in a switch statement.
File
-
vendor/
symfony/ routing/ Matcher/ Dumper/ CompiledUrlMatcherDumper.php, line 416
Class
- CompiledUrlMatcherDumper
- CompiledUrlMatcherDumper creates PHP arrays to be used with CompiledUrlMatcher.
Namespace
Symfony\Component\Routing\Matcher\DumperCode
private function compileRoute(Route $route, string $name, string|array|null $vars, bool $hasTrailingSlash, bool $hasTrailingVar, array &$conditions) : array {
$defaults = $route->getDefaults();
if (isset($defaults['_canonical_route'])) {
$name = $defaults['_canonical_route'];
unset($defaults['_canonical_route']);
}
if ($condition = $route->getCondition()) {
$condition = $this->getExpressionLanguage()
->compile($condition, [
'context',
'request',
'params',
]);
$condition = $conditions[$condition] ??= (str_contains($condition, '$request') ? 1 : -1) * \count($conditions);
}
else {
$condition = null;
}
return [
[
'_route' => $name,
] + $defaults,
$vars,
array_flip($route->getMethods()) ?: null,
array_flip($route->getSchemes()) ?: null,
$hasTrailingSlash,
$hasTrailingVar,
$condition,
];
}