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

Breadcrumb

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

function AddAutoMappingConfigurationPass::getRegexp

Builds a regexp to check if a class is auto-mapped.

1 call to AddAutoMappingConfigurationPass::getRegexp()
AddAutoMappingConfigurationPass::process in vendor/symfony/validator/DependencyInjection/AddAutoMappingConfigurationPass.php
You can modify the container here before it is dumped to PHP code.

File

vendor/symfony/validator/DependencyInjection/AddAutoMappingConfigurationPass.php, line 60

Class

AddAutoMappingConfigurationPass
Injects the automapping configuration as last argument of loaders tagged with the "validator.auto_mapper" tag.

Namespace

Symfony\Component\Validator\DependencyInjection

Code

private function getRegexp(array $patterns) : ?string {
    if (!$patterns) {
        return null;
    }
    $regexps = [];
    foreach ($patterns as $pattern) {
        // Escape namespace
        $regex = preg_quote(ltrim($pattern, '\\'));
        // Wildcards * and **
        $regex = strtr($regex, [
            '\\*\\*' => '.*?',
            '\\*' => '[^\\\\]*?',
        ]);
        // If this class does not end by a slash, anchor the end
        if (!str_ends_with($regex, '\\')) {
            $regex .= '$';
        }
        $regexps[] = '^' . $regex;
    }
    return \sprintf('{%s}', implode('|', $regexps));
}

API Navigation

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