function ModuleHandler::hasImplementations
Same name in other branches
- 10 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::hasImplementations()
- 11.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::hasImplementations()
Overrides ModuleHandlerInterface::hasImplementations
2 calls to ModuleHandler::hasImplementations()
- ModuleHandler::implementsHook in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Returns whether a given module implements a given hook.
- ModuleHandler::invoke in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Invokes a hook in a particular module.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 368
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
public function hasImplementations(string $hook, $modules = NULL) : bool {
if ($modules !== NULL) {
foreach ((array) $modules as $module) {
// Hook implementations usually found in a module's .install file are
// not stored in the implementation info cache. In order to invoke hooks
// like hook_schema() and hook_requirements() the module's .install file
// must be included by the calling code. Additionally, this check avoids
// unnecessary work when a hook implementation is present in a module's
// .module file.
if (function_exists($module . '_' . $hook)) {
return TRUE;
}
}
}
$implementations = $this->getImplementationInfo($hook);
if ($modules === NULL && !empty($implementations)) {
return TRUE;
}
return !empty(array_intersect((array) $modules, array_keys($implementations)));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.