Example #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_
Example #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_
Example #3
0
def hook(plugin_, hook_):
  """
   Determine whether a plugin implements a hook.
  
   @param plugin
     The name of the plugin (without the .plugin extension).
   @param hook
     The name of the hook (e.g. "help" or "menu").
   @return
     True if the plugin is both installed and enabled, and the hook is
     implemented in that plugin.
  """
  global plugins
  function = hook_;
  if (lib_bootstrap.MAINTENANCE_MODE is True):
    return php.function_exists(function, plugins[plugin_])
  else:
    return lib_bootstrap.drupal_function_exists(function, plugins[plugin_]);
Example #4
0
def hook(plugin_, hook_):
    """
   Determine whether a plugin implements a hook.
  
   @param plugin
     The name of the plugin (without the .plugin extension).
   @param hook
     The name of the hook (e.g. "help" or "menu").
   @return
     True if the plugin is both installed and enabled, and the hook is
     implemented in that plugin.
  """
    global plugins
    function = hook_
    if (lib_bootstrap.MAINTENANCE_MODE is True):
        return php.function_exists(function, plugins[plugin_])
    else:
        return lib_bootstrap.drupal_function_exists(function, plugins[plugin_])