drupol

Untitled

Feb 19th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. /**
  2.  * Custom helpers.
  3.  *
  4.  * Allows you to run module_invoke_all() while skipping some modules to avoid infinite loops.
  5.  */
  6. function custom_module_invoke_all($hook, array $modules_blacklist) {
  7.   $args = func_get_args();
  8.   // Remove $hook from the arguments.
  9.   unset($args[0]);
  10.   $return = array();
  11.   foreach (module_implements($hook) as $module) {
  12.     if (in_array($module, $modules_blacklist) {
  13.       continue;
  14.     }
  15.     $function = $module . '_' . $hook;
  16.     if (function_exists($function)) {
  17.       $result = call_user_func_array($function, $args);
  18.       if (isset($result) && is_array($result)) {
  19.         $return = array_merge_recursive($return, $result);
  20.       }
  21.       elseif (isset($result)) {
  22.         $return[] = $result;
  23.       }
  24.     }
  25.   }
  26.  
  27.   return $return;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment