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

Breadcrumb

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

function AddAnnotatedClassesToCachePass::expandClasses

Expands the given class patterns using a list of existing classes.

Parameters

array $patterns The class patterns to expand:

array $classes The existing classes to match against the patterns:

1 call to AddAnnotatedClassesToCachePass::expandClasses()
AddAnnotatedClassesToCachePass::process in vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php
You can modify the container here before it is dumped to PHP code.

File

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

Class

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

Namespace

Symfony\Component\HttpKernel\DependencyInjection

Code

private function expandClasses(array $patterns, array $classes) : array {
    $expanded = [];
    // Explicit classes declared in the patterns are returned directly
    foreach ($patterns as $key => $pattern) {
        if (!str_ends_with($pattern, '\\') && !str_contains($pattern, '*')) {
            unset($patterns[$key]);
            $expanded[] = ltrim($pattern, '\\');
        }
    }
    // Match patterns with the classes list
    $regexps = $this->patternsToRegexps($patterns);
    foreach ($classes as $class) {
        $class = ltrim($class, '\\');
        if ($this->matchAnyRegexps($class, $regexps)) {
            $expanded[] = $class;
        }
    }
    return array_unique($expanded);
}

API Navigation

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