[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> events.php (summary)

DokuWiki Events

Author: Christopher Smith
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
File Size: 275 lines (9 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

Doku_Event:: (9 methods):
  __construct()
  __toString()
  advise_before()
  advise_after()
  trigger()
  stopPropagation()
  mayPropagate()
  preventDefault()
  mayRunDefault()

Doku_Event_Handler:: (5 methods):
  __construct()
  register_hook()
  process_event()
  hasHandlerForEvent()
  trigger_event()


Class: Doku_Event  - X-Ref

The event

__construct($name, &$data)   X-Ref
event constructor

param: string $name
param: mixed $data

__toString()   X-Ref

return: string

advise_before($enablePreventDefault=true)   X-Ref
advise functions

advise all registered handlers of this event

if these methods are used by functions outside of this object, they must
properly handle correct processing of any default action and issue an
advise_after() signal. e.g.
$evt = new Doku_Event(name, data);
if ($evt->advise_before(canPreventDefault) {
// default action code block
}
$evt->advise_after();
unset($evt);

param: bool $enablePreventDefault
return: bool results of processing the event, usually $this->_default

advise_after()   X-Ref
No description

trigger($action=null, $enablePrevent=true)   X-Ref
trigger

- advise all registered (<event>_BEFORE) handlers that this event is about to take place
- carry out the default action using $this->data based on $enablePrevent and
$this->_default, all of which may have been modified by the event handlers.
- advise all registered (<event>_AFTER) handlers that the event has taken place

param: null|callable $action
param: bool $enablePrevent
return: mixed $event->results

stopPropagation()   X-Ref
stopPropagation

stop any further processing of the event by event handlers
this function does not prevent the default action taking place

mayPropagate()   X-Ref
may the event propagate to the next handler?

return: bool

preventDefault()   X-Ref
preventDefault

prevent the default action taking place

mayRunDefault()   X-Ref
should the default action be executed?

return: bool

Class: Doku_Event_Handler  - X-Ref

Controls the registration and execution of all events,

__construct()   X-Ref
event_handler

constructor, loads all action plugins and calls their register() method giving them
an opportunity to register any hooks they require

register_hook($event, $advise, $obj, $method, $param=null, $seq=0)   X-Ref
register_hook

register a hook for an event

param: string   $event   string   name used by the event, (incl '_before' or '_after' for triggers)
param: string   $advise
param: object   $obj     object in whose scope method is to be executed,
param: string   $method  event handler function
param: mixed    $param   data passed to the event handler
param: int      $seq     sequence number for ordering hook execution (ascending)

process_event($event,$advise='')   X-Ref
process the before/after event

param: Doku_Event $event
param: string     $advise BEFORE or AFTER

hasHandlerForEvent($name, $advise = '')   X-Ref
Check if an event has any registered handlers

When $advise is empty, both BEFORE and AFTER events will be considered,
otherwise only the given advisory is checked

param: string $name Name of the event
param: string $advise BEFORE, AFTER or empty
return: bool

trigger_event($name, &$data, $action=null, $canPreventDefault=true)   X-Ref
trigger_event

function wrapper to process (create, trigger and destroy) an event

param: string   $name               name for the event
param: mixed    $data               event data
param: callback $action             (optional, default=NULL) default action, a php callback function
param: bool     $canPreventDefault  (optional, default=true) can hooks prevent the default action
return: mixed                        the event results value after all event processing is complete