module_implements

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, $reset = 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.

Return value

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

Related topics

▾ 10 functions call module_implements()

comment_invoke_comment in modules/comment.module
Invoke a hook_comment() operation in all modules.
drupal_get_form in includes/form.inc
Processes a form array and produces the HTML output of a form. If there is input in the $_POST['edit'] variable, this function will attempt to validate it, using drupal_validate_form(), and then submit the form using drupal_submit_form().
help_links_as_list in modules/help.module
help_menu in modules/help.module
Implementation of hook_menu().
module_invoke_all in includes/module.inc
Invoke a hook in all enabled modules that implement it.
node_invoke_nodeapi in modules/node.module
Invoke a hook_nodeapi() operation in all modules.
search_preprocess in modules/search.module
Invokes hook_search_preprocess() in modules.
upload_js in modules/upload.module
Menu-callback for JavaScript-based uploads.
_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.

Code

includes/module.inc, line 142

<?php
function module_implements($hook, $sort = FALSE) {
  static $implementations;

  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];
}
?>
Login or register to post comments
 
 

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.