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

Breadcrumb

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

function AddAnnotatedClassesToCachePass::patternsToRegexps

1 call to AddAnnotatedClassesToCachePass::patternsToRegexps()
AddAnnotatedClassesToCachePass::expandClasses in vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php
Expands the given class patterns using a list of existing classes.

File

vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php, line 106

Class

AddAnnotatedClassesToCachePass
Sets the classes to compile in the cache for the container.

Namespace

Symfony\Component\HttpKernel\DependencyInjection

Code

private function patternsToRegexps(array $patterns) : array {
    $regexps = [];
    foreach ($patterns as $pattern) {
        // Escape user input
        $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 $regexps;
}

API Navigation

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