function rules_invoke_all

Invokes a hook and the associated rules event.

Calling this function does the same as calling module_invoke_all() and rules_invoke_event() separately, however merges both functions into one in order to ease usage and to work efficiently.

Parameters

$hook: The name of the hook / event to invoke.

...: Arguments to pass to the hook / event.

Return value

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

File

./rules.module, line 1050

Code

function rules_invoke_all() {
  // Copied code from module_invoke_all().
  $args = func_get_args();
  $hook = $args[0];
  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;
      }
    }
  }
  // Invoke the event.
  rules_invoke_event_by_args($hook, $args);
  return $return;
}