function Route::extractInlineDefaultsAndRequirements
2 calls to Route::extractInlineDefaultsAndRequirements()
- Route::setHost in vendor/
symfony/ routing/ Route.php - Route::setPath in vendor/
symfony/ routing/ Route.php
File
-
vendor/
symfony/ routing/ Route.php, line 413
Class
- Route
- A Route describes a route and its parameters.
Namespace
Symfony\Component\RoutingCode
private function extractInlineDefaultsAndRequirements(string $pattern) : string {
if (false === strpbrk($pattern, '?<:')) {
return $pattern;
}
$mapping = $this->getDefault('_route_mapping') ?? [];
$pattern = preg_replace_callback('#\\{(!?)([\\w\\x80-\\xFF]++)(:[\\w\\x80-\\xFF]++)?(<.*?>)?(\\?[^\\}]*+)?\\}#', function ($m) use (&$mapping) {
if (isset($m[5][0])) {
$this->setDefault($m[2], '?' !== $m[5] ? substr($m[5], 1) : null);
}
if (isset($m[4][0])) {
$this->setRequirement($m[2], substr($m[4], 1, -1));
}
if (isset($m[3][0])) {
$mapping[$m[2]] = substr($m[3], 1);
}
return '{' . $m[1] . $m[2] . '}';
}, $pattern);
if ($mapping) {
$this->setDefault('_route_mapping', $mapping);
}
return $pattern;
}