function module_hook

Determines whether a module implements a hook.

Parameters

$module: The name of the module (without the .module extension).

$hook: The name of the hook (e.g. "help" or "menu").

Return value

TRUE if the module is both installed and enabled, and the hook is implemented in that module.

Related topics

10 calls to module_hook()
config_import_invoke_owner in drupal/core/includes/config.inc
Invokes MODULE_config_import() callbacks for configuration changes.
drupal_check_module in drupal/core/includes/install.inc
Checks a module's requirements.
field_help in drupal/core/modules/field/field.module
Implements hook_help().
field_system_info_alter in drupal/core/modules/field/field.module
Implements hook_system_info_alter().
help_page in drupal/core/modules/help/help.admin.inc
Page callback: Prints a page listing general help for a module.

... See full list

File

drupal/core/includes/module.inc, line 777
API for loading and interacting with Drupal modules.

Code

function module_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
  // optional include file registered via hook_hook_info().
  $hook_info = module_hook_info();
  if (isset($hook_info[$hook]['group'])) {
    module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
    if (function_exists($function)) {
      return TRUE;
    }
  }
  return FALSE;
}