module_invoke_all

includes/module.inc, line 196

Versions
4.6 – 7
module_invoke_all()

Invoke a hook in all enabled modules that implement it.

Parameters

$hook The name of the hook to invoke.

... Arguments to pass to the hook.

Return value

An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array.

Related topics

▾ 26 functions call module_invoke_all()

comment_render in modules/comment.module
drupal_goto in includes/common.inc
Send the user to a different Drupal page.
drupal_page_footer in includes/common.inc
Perform end-of-request tasks.
file_download in includes/file.inc
node_access_grants in modules/node.module
Fetch an array of permission IDs granted to the given user ID.
node_add in modules/node.module
Present a node submission form or a set of links to such forms.
node_view in modules/node.module
Generate a display of the given node.
poll_view in modules/poll.module
Implementation of hook_view().
search_settings in modules/search.module
Menu callback; displays the search module settings page.
search_wipe in modules/search.module
Wipes a part of or the entire search index.
taxonomy_del_term in modules/taxonomy.module
taxonomy_del_vocabulary in modules/taxonomy.module
taxonomy_form_term in modules/taxonomy.module
taxonomy_form_vocabulary in modules/taxonomy.module
Display form for adding and editing vocabularies.
taxonomy_save_term in modules/taxonomy.module
taxonomy_save_vocabulary in modules/taxonomy.module
theme_closure in includes/theme.inc
Execute hook_footer() which is run at the end of the page right before the close of the body tag.
theme_comment_flat_expanded in modules/comment.module
theme_comment_thread_expanded in modules/comment.module
user_confirm_delete_submit in modules/user.module
user_logout in modules/user.module
Menu callback; logs the current user out, and redirects to the home page.
_drupal_bootstrap_full in includes/common.inc
_menu_append_contextual_items in includes/menu.inc
Account for menu items that are only defined at certain paths, so will not be cached.
_menu_build in includes/menu.inc
Build the menu by querying both modules and the database.
_node_names in modules/node.module
_ping_notify in modules/ping.module
Call hook_ping() in all modules to notify remote sites that there is new content at this one.

Code

<?php
function module_invoke_all() {
  $args = func_get_args();
  $hook = array_shift($args);
  $return = array();
  foreach (module_implements($hook) as $module) {
    $function = $module .'_'. $hook;
    $result = call_user_func_array($function, $args);
    if (isset($result) && is_array($result)) {
      $return = array_merge($return, $result);
    }
    else if (isset($result)) {
      $return[] = $result;
    }
  }

  return $return;
}
?>
 
 

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.