From 8cd947d1734727c21cd6450c4fb987279204328e Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 22 Oct 2010 10:48:16 +0000 Subject: better creation of event and plugin hook registration arrays git-svn-id: http://code.elgg.org/elgg/trunk@7115 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'engine/lib/elgglib.php') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index b73a6599a..c66d952ca 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -982,9 +982,11 @@ function register_elgg_event_handler($event, $object_type, $function, $priority if (!isset($CONFIG->events)) { $CONFIG->events = array(); - } else if (!isset($CONFIG->events[$event])) { + } + if (!isset($CONFIG->events[$event])) { $CONFIG->events[$event] = array(); - } else if (!isset($CONFIG->events[$event][$object_type])) { + } + if (!isset($CONFIG->events[$event][$object_type])) { $CONFIG->events[$event][$object_type] = array(); } @@ -1156,16 +1158,18 @@ function trigger_elgg_event($event, $object_type, $object = null) { function register_plugin_hook($hook, $type, $callback, $priority = 500) { global $CONFIG; + if (empty($hook) || empty($type)) { + return FALSE; + } + if (!isset($CONFIG->hooks)) { $CONFIG->hooks = array(); - } else if (!isset($CONFIG->hooks[$hook]) && !empty($hook)) { + } + if (!isset($CONFIG->hooks[$hook])) { $CONFIG->hooks[$hook] = array(); - } else if (!isset($CONFIG->hooks[$hook][$type]) && !empty($type)) { - $CONFIG->hooks[$hook][$type] = array(); } - - if (empty($hook) && empty($type)) { - return FALSE; + if (!isset($CONFIG->hooks[$hook][$type])) { + $CONFIG->hooks[$hook][$type] = array(); } if (!is_callable($callback)) { -- cgit v1.2.3