function module_invoke_all

Invokes 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

133 calls to module_invoke_all()
action_delete in drupal/core/modules/action/action.module
Deletes a single action from the database.
action_list in drupal/core/modules/action/action.module
Discovers all available actions by invoking hook_action_info().
AdminTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php
Sets up a Drupal site for running functional and integration tests.
aggregator_remove in drupal/core/modules/aggregator/aggregator.module
Removes all items from a feed.
Analyzer::getMessages in drupal/core/modules/views/lib/Drupal/views/Analyzer.php
Analyzes a review and return the results.

... See full list

File

drupal/core/includes/module.inc, line 993
API for loading and interacting with Drupal modules.

Code

function module_invoke_all($hook) {
  $args = func_get_args();

  // Remove $hook from the arguments.
  unset($args[0]);
  $return = array();
  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;
    if (function_exists($function)) {
      $result = call_user_func_array($function, $args);
      if (isset($result) && is_array($result)) {
        $return = array_merge_recursive($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
  }
  return $return;
}