function ModuleHandler::getHookImplementationList
Gets a hook implementation list for a specific hook.
Parameters
string $hook: The hook name.
Return value
\Drupal\Core\Hook\ImplementationList Object with hook implementation callbacks and their modules.
5 calls to ModuleHandler::getHookImplementationList()
- ModuleHandler::getCombinedListeners in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Builds a list of implementations for an alter hook.
- ModuleHandler::hasImplementations in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Determines whether there are implementations of a hook.
- ModuleHandler::invoke in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Invokes a hook in a particular module.
- ModuleHandler::invokeAllWith in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Executes a callback for each implementation of a hook.
- ModuleHandler::triggerDeprecationError in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Triggers an E_USER_DEPRECATED error if any module implements the hook.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 726
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
protected function getHookImplementationList(string $hook) : ImplementationList {
if (!isset($this->hookImplementationLists[$hook])) {
if ($this->hookLists === NULL) {
if ($cache = $this->cache
->get('hook_data')) {
$hook_data = $cache->data;
}
else {
$hook_data = $this->keyValueFactory
->get('hook_data')
->getMultiple([
'hook_list',
'includes',
'group_includes',
'packed_order_operations',
]);
$this->cache
->set('hook_data', $hook_data);
}
$this->hookLists = $hook_data['hook_list'] ?? [];
$this->hookIncludes = $hook_data['includes'] ?? [];
$this->hookGroupIncludes = $hook_data['group_includes'] ?? [];
$this->packedOrderOperations = $hook_data['packed_order_operations'] ?? [];
}
$hook_list = $this->hookLists[$hook] ?? [];
if ($hook_list) {
$listeners = [];
$modules = [];
foreach ($this->hookIncludes[$hook] ?? [] as $include) {
include_once $include;
}
foreach ($this->hookGroupIncludes[$hook] ?? [] as $include) {
@trigger_error('Autoloading hooks in the file (' . $include . ') is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Move the functions in this file to either the .module file or other appropriate location. See https://www.drupal.org/node/3489765', E_USER_DEPRECATED);
include_once $include;
}
foreach ($hook_list as $identifier => $module) {
// Remove implementations from "other" modules.
// This is relevant on the update page, when only the implementations
// from system module should be used.
if (isset($this->moduleList[$module])) {
$listeners[] = $this->callableResolver
->getCallableFromDefinition($identifier);
$modules[] = $module;
}
}
$list = new ImplementationList($listeners, $modules);
$this->hookImplementationLists[$hook] = $list;
}
else {
// Set an empty implementation list.
$this->hookImplementationLists[$hook] = new ImplementationList([], []);
}
}
return $this->hookImplementationLists[$hook];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.