function module_implements

7.x module.inc module_implements($hook, $sort = FALSE, $reset = FALSE)
6.x module.inc module_implements($hook, $sort = FALSE, $refresh = FALSE)

Determine which modules are implementing a hook.

Parameters

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

$sort: By default, modules are ordered by weight and filename, settings this option to TRUE, module list will be ordered by module name.

$refresh: For internal use only: Whether to force the stored list of hook implementations to be regenerated (such as after enabling a new module, before processing hook_enable).

Return value

An array with the names of the modules which are implementing this hook.

Related topics

21 calls to module_implements()
block_list in drupal-6.x/modules/block/block.module
Return all blocks in the specified region for the current user.
comment_invoke_comment in drupal-6.x/modules/comment/comment.module
Invoke a hook_comment() operation in all modules.
drupal_alter in drupal-6.x/includes/common.inc
Hands off alterable variables to type-specific *_alter implementations.
drupal_get_schema in drupal-6.x/includes/common.inc
Get the schema definition of a table, or the whole database schema.
help_links_as_list in drupal-6.x/modules/help/help.admin.inc

... See full list

File

drupal-6.x/includes/module.inc, line 430
API for loading and interacting with Drupal modules.

Code

function module_implements($hook, $sort = FALSE, $refresh = FALSE) {
  static $implementations;

  if ($refresh) {
    $implementations = array();
    return;
  }

  if (!isset($implementations[$hook])) {
    $implementations[$hook] = array();
    $list = module_list(FALSE, TRUE, $sort);
    foreach ($list as $module) {
      if (module_hook($module, $hook)) {
        $implementations[$hook][] = $module;
      }
    }
  }

  // The explicit cast forces a copy to be made. This is needed because
  // $implementations[$hook] is only a reference to an element of
  // $implementations and if there are nested foreaches (due to nested node
  // API calls, for example), they would both manipulate the same array's
  // references, which causes some modules' hooks not to be called.
  // See also http://www.zend.com/zend/art/ref-count.php.
  return (array) $implementations[$hook];
}