module_implements

includes/module.inc, line 403

Versions
4.6
module_implements($hook)
4.7
module_implements($hook, $sort = FALSE)
5 – 6
module_implements($hook, $sort = FALSE, $refresh = FALSE)
7
module_implements($hook, $sort = 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

▾ 20 functions call module_implements()

block_list in modules/block/block.module
Return all blocks in the specified region for the current user.
comment_invoke_comment in modules/comment/comment.module
Invoke a hook_comment() operation in all modules.
drupal_alter in includes/common.inc
This dispatch function hands off structured Drupal arrays to type-specific *_alter implementations. It ensures a consistent interface for all altering operations.
drupal_get_schema in includes/common.inc
Get the schema definition of a table, or the whole database schema.
help_links_as_list in modules/help/help.admin.inc
help_menu in modules/help/help.module
Implementation of hook_menu().
menu_router_build in includes/menu.inc
Collect, alter and store the menu definitions.
module_disable in includes/module.inc
Disable a given set of modules.
module_enable in includes/module.inc
Enable a given list of modules.
module_invoke_all in includes/module.inc
Invoke a hook in all enabled modules that implement it.
node_access_rebuild in modules/node/node.module
Rebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
node_access_write_grants in modules/node/node.module
This function will write a list of grants to the database, deleting any pre-existing grants. If a realm is provided, it will only delete grants from that realm, but it will always delete a grant from the 'all' realm. Modules which utilize...
node_invoke_nodeapi in modules/node/node.module
Invoke a hook_nodeapi() operation in all modules.
search_invoke_preprocess in modules/search/search.module
Invokes hook_search_preprocess() in modules.
search_menu in modules/search/search.module
Implementation of hook_menu().
system_performance_settings in modules/system/system.admin.inc
Form builder; Configure site performance settings. See alsosystem_settings_form()
watchdog in includes/bootstrap.inc
Log a system message.
_db_rewrite_sql in includes/database.inc
Helper function for db_rewrite_sql.
_element_info in includes/form.inc
Retrieve the default properties for the defined element type.
_theme_build_registry in includes/theme.inc
Rebuild the hook theme_registry cache.

Code

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

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.