module_hook

  1. drupal
    1. 4.7 module.inc
    2. 5 module.inc
    3. 6
    4. 7
Versions
4.7 – 7 module_hook($module, $hook)

Determine 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

▾ 8 functions call module_hook()

drupal_check_module in drupal/includes/install.inc
Check a module's requirements.
field_help in drupal/modules/field/field.module
Implements hook_help().
help_page in drupal/modules/help/help.admin.inc
Menu callback; prints a page listing general help for a module.
module_disable in drupal/includes/module.inc
Disable a given set of modules.
module_invoke in drupal/includes/module.inc
Invoke a hook in a particular module.
node_hook in drupal/modules/node/node.module
Determine whether a node hook exists.
search_data in drupal/modules/search/search.module
Performs a search by calling hook_search_execute().
system_get_module_admin_tasks in drupal/modules/system/system.module
Generate a list of tasks offered by a specified module.

Code

drupal/includes/module.inc, line 597

<?php
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;
}
?>