devel:events
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
devel:events [2014-02-18 01:56] – [Registering to Receive an Event] link PHP_INT_MAX to php.net reference ChrisS | devel:events [2023-09-02 13:58] (current) – [On Wiki page save] Klap-in | ||
---|---|---|---|
Line 14: | Line 14: | ||
===== Event Object ===== | ===== Event Object ===== | ||
- | **class name '' | + | **Class name [[xref>dokuwiki\Extension\Event]]** |
An event object consists of: | An event object consists of: | ||
Line 22: | Line 22: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * **Private** properties | + | * **Protected** properties |
- | * '' | + | * '' |
- | * '' | + | * '' |
* **Public** methods | * **Public** methods | ||
- | * '' | + | * '' |
* '' | * '' | ||
+ | * '' | ||
* '' | * '' | ||
+ | * '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
- | * '' | + | * '' |
Line 44: | Line 46: | ||
</ | </ | ||
- | For up-to-date details of the [[xref> | + | For up-to-date details of the [[xref> |
Use '' | Use '' | ||
Line 52: | Line 54: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
===== Signalling an Event ===== | ===== Signalling an Event ===== | ||
An event can be signalled in three ways. | An event can be signalled in three ways. | ||
- | - The simplest is to use the function wrapper | + | - The simplest is to use the function wrapper [[xref>Event:: |
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
- | * return //mixed//, the event result value after all event processing is complete. By default this is the return value of the default action. However it can be set or modified by event handlers hooks as it is stored in '' | + | * return //mixed//, the event result value after all event processing is complete. By default this is the return value of the default action. However it can be set or modified by event handlers hooks as it is stored in '' |
- | trigger_event(< | + | Event:: |
<action callback>, | <action callback>, | ||
</ | </ | ||
- | - using the [[xref> | + | - using the [[xref> |
- | $evt = new Doku_Event(< | + | $event = new dokuwiki\Extension\Event(< |
- | $evt-> | + | $event-> |
- | unset($evt); | + | unset($event); |
</ | </ | ||
- | - managing the whole event signalling process with [[xref>advise_before()|advise_before($enablePreventDefault = true)]] and [[xref>advise_after()|advise_after()]] on the [[xref>Doku_Event]] object. | + | - managing the whole event signalling process with [[xref> |
- | $evt = new Doku_Event(< | + | $event = new dokuwiki\Extension\Event(< |
- | if ($evt-> | + | if ($event-> |
// default action code block | // default action code block | ||
} | } | ||
- | $evt-> | + | $event-> |
- | unset($evt); | + | unset($event); |
</ | </ | ||
Line 87: | Line 90: | ||
<code php> | <code php> | ||
+ | use dokuwiki\Extension\Event; | ||
+ | |||
// event: | // event: | ||
// data: | // data: | ||
// action: save the raw wiki page to file name | // action: save the raw wiki page to file name | ||
// return: bool, page saved | // return: bool, page saved | ||
- | $data = array($id, | + | $data = [$id, $wikitext]; |
- | $ok = trigger_event(' | + | $ok = Event:: |
</ | </ | ||
Line 106: | Line 111: | ||
// in '' | // in '' | ||
- | $evt = new Doku_Event(' | + | $event = new dokuwiki\Extension\Event(' |
- | if ($evt-> | + | if ($event-> |
/* process $ACT normally */ | /* process $ACT normally */ | ||
} | } | ||
- | $evt-> | + | $event-> |
- | unset($evt); | + | unset($event); |
// in '' | // in '' | ||
- | default: | + | // default: unrecognised $ACT value |
- | $evt = new Doku_Event(' | + | $event = new dokuwiki\Extension\Event(' |
- | if ($evt-> | + | if ($event-> |
print " | print " | ||
} | } | ||
- | $evt-> | + | $event-> |
- | unset($evt); | + | unset($event); |
</ | </ | ||
Possible handlers, customer form processing, additional '' | Possible handlers, customer form processing, additional '' | ||
Line 127: | Line 132: | ||
==== On handler instruction list completion ==== | ==== On handler instruction list completion ==== | ||
<code php> | <code php> | ||
- | | + | use dokuwiki\Extension\Event; |
- | // data: the handler, including the completed instruction list | + | |
- | // action: none | + | // event: |
+ | // data: the handler, including the completed instruction list | ||
+ | // action: none | ||
| | ||
- | | + | // in '' |
- | | + | Event:: |
</ | </ | ||
possible handlers, footnote replacement plugins, enhanced TOC handlers | possible handlers, footnote replacement plugins, enhanced TOC handlers |
devel/events.1392685011.txt.gz · Last modified: 2014-02-18 01:56 by ChrisS