XOOPS
2.6.0
|
Public Member Functions | |
addListener ($eventName, $callback) | |
getEvents () | |
hasListeners ($eventName) | |
initializeListeners () | |
triggerEvent ($eventName, $args=array()) | |
Static Public Member Functions | |
static | getInstance () |
Protected Member Functions | |
__construct () | |
setEvents () | |
setPreloads () | |
toInternalEventName ($eventName) | |
Protected Attributes | |
$eventListeners = array() | |
$eventsEnabled = true | |
$preloadList = array() | |
Definition at line 27 of file Events.php.
|
protected |
Constructor
Definition at line 48 of file Events.php.
Xoops\Core\Events::addListener | ( | $eventName, | |
$callback | |||
) |
addListener - add a listener, providing a callback for a specific event.
string | $eventName | the event name |
callable | $callback | any callable acceptable for call_user_func |
Definition at line 209 of file Events.php.
References Xoops\Core\Events\toInternalEventName().
Xoops\Core\Events::getEvents | ( | ) |
getEvents - for debugging only, return list of event listeners
Definition at line 220 of file Events.php.
References Xoops\Core\Events\$eventListeners.
|
static |
Allow one instance only!
Definition at line 57 of file Events.php.
Referenced by Xoops\Core\Service\Provider\__call(), XoopsDatabaseFactory\getDatabaseConnection(), MyTextSanitizer\getSmileys(), SystemModule\install(), SystemModule\installconfigs(), XoopsMySQLDatabase\queryF(), smarty_function_xoInboxCount(), MyTextSanitizer\smiley(), and SystemModule\uninstall().
Xoops\Core\Events::hasListeners | ( | $eventName | ) |
hasListeners - for debugging only, return list of event listeners
type | $eventName | event name |
Definition at line 231 of file Events.php.
References Xoops\Core\Events\toInternalEventName().
Xoops\Core\Events::initializeListeners | ( | ) |
initializePreloads - Initialize listeners with preload mapped events.
We supress event processing during establishing listener map. A a cache miss (on system_modules_active, for example) triggers regeneration, which may trigger events that listeners are not prepared to handle. In such circumstances, module level class mapping will not have been done.
Definition at line 78 of file Events.php.
References Xoops\Core\Events\setEvents(), and Xoops\Core\Events\setPreloads().
|
protected |
Load all preload files and add all listener methods to eventListeners
Preload classes contain methods based on event names. We extract those method names and store to compare against when an event is triggered.
Example: An event is triggered as 'core.include.common.end' A PreloadItem class can listen for this event by declaring a static method 'eventCoreIncludeCommonEnd()'
PreloadItem class files can be named for the specific source of the events, such as core.php, system.php, etc. In such case the class name is built from the concatenation of the module name, the source and the literal 'Preload'. This mechanism is now considered deprecated. As an example, a module named 'Example' can listen for 'core' events with a file named preloads/core.php, containing a class ExampleCorePreload
The prefered preload definition is the unified preloads/preload.php file containing a single PreloadItem class name concatenating the module name and the literal 'Preload'. This class can listen for events from any source.
Definition at line 145 of file Events.php.
Referenced by Xoops\Core\Events\initializeListeners().
|
protected |
Get list of all available preload files
Definition at line 91 of file Events.php.
References $dir, $file, $i, Xoops\$module, XoopsBaseConfig\get(), and Xoops\getInstance().
Referenced by Xoops\Core\Events\initializeListeners().
|
protected |
toInternalEventName - convert event name to internal form i.e. core.include.common.end becomes coreincludecommonend
string | $eventName | the event name |
Definition at line 196 of file Events.php.
Referenced by Xoops\Core\Events\addListener(), Xoops\Core\Events\hasListeners(), and Xoops\Core\Events\triggerEvent().
Xoops\Core\Events::triggerEvent | ( | $eventName, | |
$args = array() |
|||
) |
Trigger a specific event
string | $eventName | Name of the event to trigger |
mixed | $args | Method arguments |
Definition at line 174 of file Events.php.
References Xoops\Core\Events\toInternalEventName().
|
protected |
key is event name, value is array of callables
Definition at line 38 of file Events.php.
Referenced by Xoops\Core\Events\getEvents().
|
protected |
bool $eventsEnabled
Definition at line 43 of file Events.php.
|
protected |
Definition at line 32 of file Events.php.