Same name and namespace in other branches
- 4.6.x includes/module.inc \module_invoke_all()
- 4.7.x includes/module.inc \module_invoke_all()
- 5.x includes/module.inc \module_invoke_all()
- 7.x includes/module.inc \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
42 calls to module_invoke_all()
- actions_delete in includes/
actions.inc - Delete a single action from the database.
- actions_list in includes/
actions.inc - Discover all action functions by invoking hook_action_info().
- comment_render in modules/
comment/ comment.module - Renders comment(s).
- drupal_flush_all_caches in includes/
common.inc - Flush all cached data on the site.
- drupal_goto in includes/
common.inc - Send the user to a different Drupal page.
File
- includes/
module.inc, line 490 - API for loading and interacting with Drupal modules.
Code
function module_invoke_all() {
$args = func_get_args();
$hook = $args[0];
unset($args[0]);
$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_recursive($return, $result);
}
else {
if (isset($result)) {
$return[] = $result;
}
}
}
return $return;
}