From b95f23779af7f11a622a0e978c4a5a0917b8c76e Mon Sep 17 00:00:00 2001 From: ewinslow Date: Thu, 11 Nov 2010 10:12:38 +0000 Subject: Obliterated C&P in elgg_trigger_plugin_hook git-svn-id: http://code.elgg.org/elgg/trunk@7298 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 63d2e046a..d369f0fdc 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1028,42 +1028,21 @@ function unregister_plugin_hook($hook, $entity_type, $callback) { function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) { global $CONFIG; - if (!empty($CONFIG->hooks[$hook][$type]) && is_array($CONFIG->hooks[$hook][$type])) { - foreach ($CONFIG->hooks[$hook][$type] as $hookcallback) { - $temp_return_value = call_user_func_array($hookcallback, - array($hook, $type, $returnvalue, $params)); - if (!is_null($temp_return_value)) { - $returnvalue = $temp_return_value; - } - } - } - - if (!empty($CONFIG->hooks['all'][$type]) && is_array($CONFIG->hooks['all'][$type])) { - foreach ($CONFIG->hooks['all'][$type] as $hookcallback) { - $temp_return_value = call_user_func_array($hookcallback, - array($hook, $type, $returnvalue, $params)); - if (!is_null($temp_return_value)) { - $returnvalue = $temp_return_value; - } - } - } - - if (!empty($CONFIG->hooks[$hook]['all']) && is_array($CONFIG->hooks[$hook]['all'])) { - foreach ($CONFIG->hooks[$hook]['all'] as $hookcallback) { - $temp_return_value = call_user_func_array($hookcallback, - array($hook, $type, $returnvalue, $params)); - if (!is_null($temp_return_value)) { - $returnvalue = $temp_return_value; - } - } - } + $hooks = array( + $CONFIG->hooks[$hook][$type], + $CONFIG->hooks['all'][$type], + $CONFIG->hooks[$hook]['all'], + $CONFIG->hooks['all']['all'], + ); - if (!empty($CONFIG->hooks['all']['all']) && is_array($CONFIG->hooks['all']['all'])) { - foreach ($CONFIG->hooks['all']['all'] as $hookcallback) { - $temp_return_value = call_user_func_array($hookcallback, - array($hook, $type, $returnvalue, $params)); - if (!is_null($temp_return_value)) { - $returnvalue = $temp_return_value; + foreach ($hooks as $callback_list) { + if (is_array($callback_list)) { + foreach ($callback_list as $hookcallback) { + $args = array($hook, $type, $returnvalue, $params); + $temp_return_value = call_user_func_array($hookcallback, $args); + if (!is_null($temp_return_value)) { + $returnvalue = $temp_return_value; + } } } } -- cgit v1.2.3