function module_hook_info

Retrieves a list of hooks that are declared through hook_hook_info().

Return value

An associative array whose keys are hook names and whose values are an associative array containing a group name. The structure of the array is the same as the return value of hook_hook_info().

See also

hook_hook_info()

Related topics

2 calls to module_hook_info()
module_hook in drupal/core/includes/module.inc
Determines whether a module implements a hook.
module_implements in drupal/core/includes/module.inc
Determines which modules are implementing a hook.
1 string reference to 'module_hook_info'
module_implements_reset in drupal/core/includes/module.inc
Regenerates the stored list of hook implementations.

File

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

Code

function module_hook_info() {

  // When this function is indirectly invoked from bootstrap_invoke_all() prior
  // to all modules being loaded, we do not want to cache an incomplete
  // hook_hook_info() result, so instead return an empty array. This requires
  // bootstrap hook implementations to reside in the .module file, which is
  // optimal for performance anyway.
  if (!module_load_all(NULL)) {
    return array();
  }
  $hook_info =& drupal_static(__FUNCTION__);
  if (!isset($hook_info)) {
    $hook_info = array();
    $cache = cache('bootstrap')
      ->get('hook_info');
    if ($cache === FALSE) {

      // Rebuild the cache and save it.
      // We can't use module_invoke_all() here or it would cause an infinite
      // loop.
      foreach (module_list() as $module) {
        $function = $module . '_hook_info';
        if (function_exists($function)) {
          $result = $function();
          if (isset($result) && is_array($result)) {
            $hook_info = array_merge_recursive($hook_info, $result);
          }
        }
      }

      // We can't use drupal_alter() for the same reason as above.
      foreach (module_list() as $module) {
        $function = $module . '_hook_info_alter';
        if (function_exists($function)) {
          $function($hook_info);
        }
      }
      cache('bootstrap')
        ->set('hook_info', $hook_info);
    }
    else {
      $hook_info = $cache->data;
    }
  }
  return $hook_info;
}