Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Route.php

function Route::sanitizeRequirement

2 calls to Route::sanitizeRequirement()
Route::addRequirements in vendor/symfony/routing/Route.php
Route::setRequirement in vendor/symfony/routing/Route.php

File

vendor/symfony/routing/Route.php, line 442

Class

Route
A Route describes a route and its parameters.

Namespace

Symfony\Component\Routing

Code

private function sanitizeRequirement(string $key, string $regex) : string {
    if ('' !== $regex) {
        if ('^' === $regex[0]) {
            $regex = substr($regex, 1);
        }
        elseif (str_starts_with($regex, '\\A')) {
            $regex = substr($regex, 2);
        }
    }
    if (str_ends_with($regex, '$')) {
        $regex = substr($regex, 0, -1);
    }
    elseif (\strlen($regex) - 2 === strpos($regex, '\\z')) {
        $regex = substr($regex, 0, -2);
    }
    if ('' === $regex) {
        throw new \InvalidArgumentException(\sprintf('Routing requirement for "%s" cannot be empty.', $key));
    }
    return $regex;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal