function HookCollectorPass::getModuleListPattern

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

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

Parameters

list<string> $module_list: A list of module names.

Return value

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

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

File

core/lib/Drupal/Core/Hook/HookCollectorPass.php, line 387

Class

HookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

protected static function getModuleListPattern(array $module_list) : string {
  usort($module_list, static fn($a, $b) => strlen($b) - strlen($a));
  $module_pattern = implode('|', array_map(static fn($x) => preg_quote($x, '/'), $module_list));
  return '/^(?<function>(?<module>' . $module_pattern . ')_(?!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.