本文整理汇总了Python中lib.drupy.DrupyPHP.call_user_func_array方法的典型用法代码示例。如果您正苦于以下问题:Python DrupyPHP.call_user_func_array方法的具体用法?Python DrupyPHP.call_user_func_array怎么用?Python DrupyPHP.call_user_func_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.drupy.DrupyPHP
的用法示例。
在下文中一共展示了DrupyPHP.call_user_func_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invoke_all
# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import call_user_func_array [as 别名]
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_
示例2: invoke
# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import call_user_func_array [as 别名]
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)