]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
better creation of event and plugin hook registration arrays
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 22 Oct 2010 10:48:16 +0000 (10:48 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 22 Oct 2010 10:48:16 +0000 (10:48 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7115 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php

index b73a6599a1cd3aa6d52682667d6f203916a4f116..c66d952cabb7c127037dc374660da38581b9e0cb 100644 (file)
@@ -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)) {