function HookCollectorPass::collectAllHookImplementations
Collects all hook implementations.
@internal This method is only used by ModuleHandler.
Parameters
array $module_filenames: An associative array. Keys are the module names, values are relevant info yml file path.
Return value
\Drupal\Core\Extension\HookCollectorPass A HookCollectorPass instance holding all hook implementations and include file information.
2 calls to HookCollectorPass::collectAllHookImplementations()
- HookCollectorPass::process in core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php - ModuleHandler::add in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Adds a module or profile to the list of currently active modules.
File
-
core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php, line 137
Class
- HookCollectorPass
- Collects and registers hook implementations.
Namespace
Drupal\Core\HookCode
public static function collectAllHookImplementations(array $module_filenames) : static {
$modules = array_map(fn($x) => preg_quote($x, '/'), array_keys($module_filenames));
// Longer modules first.
usort($modules, fn($a, $b) => strlen($b) - strlen($a));
$module_preg = '/^(?<function>(?<module>' . implode('|', $modules) . ')_(?!preprocess_)(?!update_\\d)(?<hook>[a-zA-Z0-9_\\x80-\\xff]+$))/';
$collector = new static();
foreach ($module_filenames as $module => $info) {
$collector->collectModuleHookImplementations(dirname($info['pathname']), $module, $module_preg);
}
return $collector->convertProceduralToImplementations();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.