diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-25 18:09:48 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-25 18:09:48 +0000 |
commit | e08531bc7cc33ae406642ef3b2fd65e4b9ea3d9d (patch) | |
tree | 0735ca446299e35f2332815e5c4dde6bc518c0ab | |
parent | dbda82da63d6462b68ae2795949766c8c5b1a95d (diff) | |
download | elgg-e08531bc7cc33ae406642ef3b2fd65e4b9ea3d9d.tar.gz elgg-e08531bc7cc33ae406642ef3b2fd65e4b9ea3d9d.tar.bz2 |
Updated documentation for register_plugin_hook().
git-svn-id: http://code.elgg.org/elgg/trunk@6212 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/elgglib.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index ec683414e..110cafcab 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1970,7 +1970,7 @@ function trigger_elgg_event($event, $object_type, $object = null) { } /** - * Register a function to a plugin hook for a particular entity type, with a given priority. + * Register a function to a plugin hook for a particular hook name and type, with a given priority. * * eg if you want the function "export_user" to be called when the hook "export" for "user" entities * is run, use: @@ -1987,32 +1987,32 @@ function trigger_elgg_event($event, $object_type, $object = null) { * $params is an array containing a set of parameters (or nothing). * * @param string $hook The name of the hook - * @param string $entity_type The name of the type of entity (eg "user", "object" etc) + * @param string $type The type of the hook (NB Can be an ElggEntity type [user, object, group, site] or custom-defined 'get_sections') * @param string $function The name of a valid function to be run * @param string $priority The priority - 0 is first, 1000 last, default is 500 * @return true|false Depending on success */ -function register_plugin_hook($hook, $entity_type, $function, $priority = 500) { +function register_plugin_hook($hook, $type, $function, $priority = 500) { global $CONFIG; if (!isset($CONFIG->hooks)) { $CONFIG->hooks = array(); } else if (!isset($CONFIG->hooks[$hook]) && !empty($hook)) { $CONFIG->hooks[$hook] = array(); - } else if (!isset($CONFIG->hooks[$hook][$entity_type]) && !empty($entity_type)) { - $CONFIG->hooks[$hook][$entity_type] = array(); + } else if (!isset($CONFIG->hooks[$hook][$type]) && !empty($type)) { + $CONFIG->hooks[$hook][$type] = array(); } - if (!empty($hook) && !empty($entity_type) && is_callable($function)) { + if (!empty($hook) && !empty($type) && is_callable($function)) { $priority = (int) $priority; if ($priority < 0) { $priority = 0; } - while (isset($CONFIG->hooks[$hook][$entity_type][$priority])) { + while (isset($CONFIG->hooks[$hook][$type][$priority])) { $priority++; } - $CONFIG->hooks[$hook][$entity_type][$priority] = $function; - ksort($CONFIG->hooks[$hook][$entity_type]); + $CONFIG->hooks[$hook][$type][$priority] = $function; + ksort($CONFIG->hooks[$hook][$type]); return true; } else { return false; |