aboutsummaryrefslogtreecommitdiff
path: root/documentation/examples/hooks/basic.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2011-11-18 07:32:27 +0100
committerSem <sembrestels@riseup.net>2011-11-18 07:32:27 +0100
commite53d410129701ea1c9d19529afa493f11b5f5b70 (patch)
treed9963b24bf8932654b4a47e36602c75975e50dba /documentation/examples/hooks/basic.php
parent377da25d2965c64941f83baae119fc970ec60982 (diff)
parent08a962c98e2923724f8013d6eaae89101243752a (diff)
downloadelgg-e53d410129701ea1c9d19529afa493f11b5f5b70.tar.gz
elgg-e53d410129701ea1c9d19529afa493f11b5f5b70.tar.bz2
Merge github.com:Elgg/Elgg
Conflicts: engine/lib/input.php
Diffstat (limited to 'documentation/examples/hooks/basic.php')
-rw-r--r--documentation/examples/hooks/basic.php41
1 files changed, 12 insertions, 29 deletions
diff --git a/documentation/examples/hooks/basic.php b/documentation/examples/hooks/basic.php
index 71076ee96..734d9e884 100644
--- a/documentation/examples/hooks/basic.php
+++ b/documentation/examples/hooks/basic.php
@@ -1,34 +1,17 @@
<?php
+/**
+ * The handler for a plugin hook receives information about the hook (name and
+ * type), the current value for the hook, and parameters related to the hook.
+ */
-elgg_register_plugin_hook_handler('get_items', 'example', 'example_plugin_hook');
-elgg_register_plugin_hook_handler('get_items', 'example', 'example_plugin_hook_2');
+elgg_register_plugin_hook_handler('forward', '404', 'example_plugin_hook_handler');
-$params = array('username' => 'Joe');
-$items = elgg_trigger_plugin_hook('get_items', 'example', $params, $default);
+function example_plugin_hook_handler($hook, $type, $value, $params) {
+ var_dump($hook);
+ var_dump($type);
+ var_dump($value);
+ var_dump($params);
-var_dump($items);
-
-function example_plugin_hook($hook, $type, $value, $params) {
- if (is_array($value)) {
- $value[] = "Hook Value 1";
- $value[] = "Hook Value 2";
- }
-
- return $value;
-}
-
-function example_plugin_hook_2($hook, $type, $value, $params) {
- $username = isset($params['username']) ? $params['username'] : NULL;
- if (is_array($value)) {
- switch($username) {
- case 'Joe':
- $value[] = "Joe's item";
- break;
- case 'John':
- $value[] = "Joe's item";
- break;
- }
- }
-
- return $value;
+ // we are not changing $value so return null
+ return null;
}