aboutsummaryrefslogtreecommitdiff
path: root/documentation/examples/hooks/basic.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-15 15:40:51 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-15 15:40:51 +0000
commitea4403c9240c3778cddc90d48d0a59c4d47dd2d8 (patch)
treed62822795c186d7de87f3f5e337283d8007dae2a /documentation/examples/hooks/basic.php
parent4d008fefd2882a51309b5c6a7c3c7775fb34270d (diff)
downloadelgg-ea4403c9240c3778cddc90d48d0a59c4d47dd2d8.tar.gz
elgg-ea4403c9240c3778cddc90d48d0a59c4d47dd2d8.tar.bz2
Adding documentation and examples.
git-svn-id: http://code.elgg.org/elgg/trunk@6933 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'documentation/examples/hooks/basic.php')
-rw-r--r--documentation/examples/hooks/basic.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/documentation/examples/hooks/basic.php b/documentation/examples/hooks/basic.php
new file mode 100644
index 000000000..fe0b847a2
--- /dev/null
+++ b/documentation/examples/hooks/basic.php
@@ -0,0 +1,34 @@
+<?php
+
+register_plugin_hook('get_items', 'example', 'example_plugin_hook');
+register_plugin_hook('get_items', 'example', 'example_plugin_hook_2');
+
+$params = array('username' => 'Joe');
+$items = trigger_plugin_hook('get_items', 'example', $params, $default);
+
+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($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;
+}