mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Clarify event documentation by adding examples
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
* XXX HIGHLY EXPERIMENTAL AND SUBJECT TO CHANGE WITHOUT NOTICE.
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -16,9 +16,13 @@ class _blank_event // plugin-folder + '_event'
|
||||
|
||||
/**
|
||||
* Configure functions/methods to run when specific e107 events are triggered.
|
||||
* For a list of events, please visit: http://e107.org/developer-manual/classes-and-methods#events
|
||||
* Developers can trigger their own events using: e107::getEvent()->trigger('plugin_event',$array);
|
||||
*
|
||||
* For a list of core events, please visit: http://e107.org/developer-manual/classes-and-methods#events
|
||||
*
|
||||
* Developers can trigger their own events using: e107::getEvent()->trigger('plugin_event', $array);
|
||||
* Where 'plugin' is the folder of their plugin and 'event' is a unique name of the event.
|
||||
* Other plugins can then 'listen' to this custom event by defining it in THEIR e_event.php addon within the config() method.
|
||||
*
|
||||
* $array is data which is sent to the triggered function. eg. myfunction($array) in the example below.
|
||||
*
|
||||
* @return array
|
||||
@@ -28,13 +32,32 @@ class _blank_event // plugin-folder + '_event'
|
||||
|
||||
$event = array();
|
||||
|
||||
// Example 1: core event ("login")
|
||||
$event[] = array(
|
||||
'name' => "login", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events)
|
||||
'function' => "myfunction", // ..run this function (see below).
|
||||
'name' => "login", // when this event is triggered... (fore core events, see http://e107.org/developer-manual/classes-and-methods#events)
|
||||
'function' => "myfunction", // ..run this function (see below).
|
||||
);
|
||||
|
||||
return $event;
|
||||
// Example 2: core plugin event ("user_forum_post_created")
|
||||
$event[] = array(
|
||||
'name' => "user_forum_post_created", // "plugin_event" where 'plugin' is the plugin folder name (in this case "_blank") and "event" is a unique event name (in this case "customevent")
|
||||
'function' => "myfunction", // ..run this function (see below). You can run the same function on different events.
|
||||
);
|
||||
|
||||
// Example 3: custom event of another third party plugin
|
||||
$event[] = array(
|
||||
'name' => "customplugin_customevent", // where "customplugin" is the plugin folder name of the third party plugin, and "customevent" is the event name that they triggered somehwere in their code (e107::getEvent()->trigger('customplugin_customevent', $data).
|
||||
'function' => "anotherfunction", // ..run this function (see below).
|
||||
);
|
||||
|
||||
// Example 4: custom event of the _blank plugin.
|
||||
// Listen to _blank's own plugin event
|
||||
$event[] = array(
|
||||
'name' => "_blank_customevent", // "plugin_event" where 'plugin' is the plugin folder name (in this case "_blank") and "event" is a unique event name (in this case "customevent")
|
||||
'function' => "anotherfunction", // ..run this function (see below).
|
||||
);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +66,9 @@ class _blank_event // plugin-folder + '_event'
|
||||
// var_dump($data);
|
||||
}
|
||||
|
||||
function anotherfunction($data) // the method to run.
|
||||
{
|
||||
// var_dump($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} //end class
|
||||
|
||||
} //end class
|
Reference in New Issue
Block a user