function ThemeHookCollectorPass::getThemeListPattern

Get a pattern used to match hooks for the given theme list.

The supplied theme list will be sorted by length in descending order so that longer names are matched first.

Parameters

list<string> $themeList: A list of theme names.

Return value

string The pattern used to match hooks for the given theme list.

1 call to ThemeHookCollectorPass::getThemeListPattern()
ThemeHookCollectorPass::collectAllHookImplementations in core/lib/Drupal/Core/Hook/ThemeHookCollectorPass.php
Collects all hook implementations.

File

core/lib/Drupal/Core/Hook/ThemeHookCollectorPass.php, line 182

Class

ThemeHookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

protected static function getThemeListPattern(array $themeList) : string {
  usort($themeList, static fn($a, $b) => strlen($b) - strlen($a));
  $themePattern = implode('|', array_map(static fn($x) => preg_quote($x, '/'), $themeList));
  return '/^(?<function>(?<theme>' . $themePattern . ')_(?!update_\\d)(?<hook>[a-zA-Z0-9_\\x80-\\xff]+$))/';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.