private function Route::sanitizeRequirement

2 calls to Route::sanitizeRequirement()
Route::addRequirements in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php
Adds requirements.
Route::setRequirement in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php
Sets a requirement for the given key.

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php, line 371

Class

Route
A Route describes a route and its parameters.

Namespace

Symfony\Component\Routing

Code

private function sanitizeRequirement($key, $regex) {
  if (!is_string($regex)) {
    throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string', $key));
  }
  if ('' === $regex) {
    throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty', $key));
  }
  if ('^' === $regex[0]) {
    $regex = substr($regex, 1);
  }
  if ('$' === substr($regex, -1)) {
    $regex = substr($regex, 0, -1);
  }
  return $regex;
}