function ModuleHandler::getHookImplementationList
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\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 634
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',
'packed_order_operations',
]);
$this->cache
->set('hook_data', $hook_data);
}
$this->hookLists = $hook_data['hook_list'] ?? [];
$this->packedOrderOperations = $hook_data['packed_order_operations'] ?? [];
}
$hook_list = $this->hookLists[$hook] ?? [];
if ($hook_list) {
$listeners = [];
$modules = [];
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.
// 'core' is a special protected module name. This is used by the test
// system to allow kernel tests to implement hooks.
if (isset($this->moduleList[$module]) || $module === 'core') {
$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.