You are here

function messaging_module_invoke_all in Messaging 6.4

Invoke hook on all modules

This is like module_invoke_all with some differences:

  • The results are just merged (not recursively)
  • The module name is added to each resulting array

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.

1 call to messaging_module_invoke_all()
messaging_info in ./messaging.module
Invoke hook_notifications($name) on all modules

File

./messaging.module, line 1234

Code

function messaging_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)) {
      foreach ($result as $key => &$value) {
        if (is_array($value)) {
          $value += array(
            'module' => $module,
          );
        }
      }
      $return = array_merge($return, $result);
    }
    else {
      if (isset($result)) {
        $return[] = $result;
      }
    }
  }
  return $return;
}