Exemple #1
0
def invoke_all(*args):
  """
   Invoke a hook in all enabled plugins that implement it.
  
   @param hook
     The name of the hook to invoke.
   @param ...
     Arguments to pass to the hook.
   @return
     An array of return values of the hook implementations. If plugins return
     arrays from their implementations, those are merged into one array.
  """
  global plugins
  args = list(args)
  hook = 'hook_%s' % args[0]
  del(args[0])
  return_ = []
  for plugin_ in implements(hook):
    if (lib_bootstrap.drupal_function_exists(hook, plugins[plugin_])):
      function = DrupyImport.getFunction(\
        plugins[plugin_], hook)
      result = php.call_user_func_array(function, args);
      if (result is not None and php.is_array(result)):
        return_ = p.array_merge_recursive(return_, result);
      elif (result is not None):
        return_.append( result );
  return return_
Exemple #2
0
def invoke_all(*args):
    """
   Invoke a hook in all enabled plugins that implement it.
  
   @param hook
     The name of the hook to invoke.
   @param ...
     Arguments to pass to the hook.
   @return
     An array of return values of the hook implementations. If plugins return
     arrays from their implementations, those are merged into one array.
  """
    global plugins
    args = list(args)
    hook = 'hook_%s' % args[0]
    del (args[0])
    return_ = []
    for plugin_ in implements(hook):
        if (lib_bootstrap.drupal_function_exists(hook, plugins[plugin_])):
            function = DrupyImport.getFunction(\
              plugins[plugin_], hook)
            result = php.call_user_func_array(function, args)
            if (result is not None and php.is_array(result)):
                return_ = p.array_merge_recursive(return_, result)
            elif (result is not None):
                return_.append(result)
    return return_
Exemple #3
0
def invoke(plugin_, hook_, *args):
  """
   Invoke a hook in a particular plugin.
  
   @param plugin
     The name of the plugin (without the .plugin extension).
   @param hook
     The name of the hook to invoke.
   @param ...
     Arguments to pass to the hook implementation.
   @return
     The return value of the hook implementation.
  """
  if (hook(plugin_, hook_)):
    function_name = 'hook_' + hook_
    function = DrupyImport.getFunction(plugins[plugin_], function_name)
    return php.call_user_func_array(function, args)
Exemple #4
0
def invoke(plugin_, hook_, *args):
    """
   Invoke a hook in a particular plugin.
  
   @param plugin
     The name of the plugin (without the .plugin extension).
   @param hook
     The name of the hook to invoke.
   @param ...
     Arguments to pass to the hook implementation.
   @return
     The return value of the hook implementation.
  """
    if (hook(plugin_, hook_)):
        function_name = 'hook_' + hook_
        function = DrupyImport.getFunction(plugins[plugin_], function_name)
        return php.call_user_func_array(function, args)