private function Route::sanitizeRequirement in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/routing/Route.php \Symfony\Component\Routing\Route::sanitizeRequirement()
2 calls to Route::sanitizeRequirement()
- Route::addRequirements in vendor/
symfony/ routing/ Route.php - Adds requirements.
- Route::setRequirement in vendor/
symfony/ routing/ Route.php - Sets a requirement for the given key.
File
- vendor/
symfony/ routing/ Route.php, line 628
Class
- Route
- A Route describes a route and its parameters.
Namespace
Symfony\Component\RoutingCode
private function sanitizeRequirement($key, $regex) {
if (!is_string($regex)) {
throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key));
}
if ('' !== $regex && '^' === $regex[0]) {
$regex = (string) substr($regex, 1);
// returns false for a single character
}
if ('$' === substr($regex, -1)) {
$regex = substr($regex, 0, -1);
}
if ('' === $regex) {
throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty.', $key));
}
// this is to keep BC and will be removed in a future version
if ('_scheme' === $key) {
@trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setSchemes() method instead.', E_USER_DEPRECATED);
$this
->setSchemes(explode('|', $regex));
}
elseif ('_method' === $key) {
@trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setMethods() method instead.', E_USER_DEPRECATED);
$this
->setMethods(explode('|', $regex));
}
return $regex;
}