function skinr_hook in Skinr 8.2
Same name and namespace in other branches
- 7.2 skinr.module \skinr_hook()
Determine whether a module implements a hook.
Replacement for ModuleHandler::implementsHook() that only invokes modules that implement the current version of Skinr API. It also supports $module.skinr.inc files in themes and custom paths.
Parameters
$module: The name of the module (without the .module extension).
$hook: The name of the hook (e.g. "skinr_skin_info" or "skinr_theme_hooks").
Return value
TRUE if the module is both installed and enabled, and the hook is implemented in that module.
2 calls to skinr_hook()
- DefaultController::skinr_test_hook_dynamic_loading in tests/
modules/ skinr_test/ src/ Controller/ DefaultController.php - skinr_test_hook_dynamic_loading in tests/
modules/ skinr_test/ skinr_test.module - Page callback for 'hook dynamic loading' test.
File
- ./
skinr.module, line 451 - Handles core Skinr functionality.
Code
function skinr_hook($module, $hook) {
$function = $module . '_' . $hook;
if (function_exists($function)) {
return TRUE;
}
// If the hook implementation does not exist, check whether it may live in an
// include file in a custom path.
$extensions = skinr_implements_api();
if (isset($extensions[$module])) {
$extension = $extensions[$module];
if (isset($extension['include file'])) {
// The module specified a custom path. ModuleHandler::implementsHook()
// only auto-loads $module.skinr.inc in a module's root folder.
skinr_load_include($extension['include file']);
if (function_exists($function)) {
return TRUE;
}
}
else {
// Run through ModuleHandler::implementsHook() to auto-load
// $module.skinr.inc from a non-custom path.
if (\Drupal::moduleHandler()
->implementsHook($module, $hook)) {
return TRUE;
}
}
}
return FALSE;
}