public ModuleHandler::implementsHook($module, $hook)
Returns whether a given module implements a given hook.
string $module: The name of the module (without the .module extension).
string $hook: The name of the hook (e.g. "help" or "menu").
bool TRUE if the module is both installed and enabled, and the hook is implemented in that module.
Overrides ModuleHandlerInterface::implementsHook
public function implementsHook($module, $hook) {
$function = $module . '_' . $hook;
if (function_exists($function)) {
return TRUE;
}
// If the hook implementation does not exist, check whether it lives in an
// optional include file registered via hook_hook_info().
$hook_info = $this->getHookInfo();
if (isset($hook_info[$hook]['group'])) {
$this->loadInclude($module, 'inc', $module . '.' . $hook_info[$hook]['group']);
if (function_exists($function)) {
return TRUE;
}
}
return FALSE;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ModuleHandler.php/function/ModuleHandler::implementsHook/8.1.x