XOOPS  2.6.0
Xoops\Core\Events Class Reference
Inheritance diagram for Xoops\Core\Events:
Inheritance graph

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()
 

Detailed Description

Definition at line 27 of file Events.php.

Constructor & Destructor Documentation

Xoops\Core\Events::__construct ( )
protected

Constructor

Definition at line 48 of file Events.php.

Member Function Documentation

Xoops\Core\Events::addListener (   $eventName,
  $callback 
)

addListener - add a listener, providing a callback for a specific event.

Parameters
string$eventNamethe event name
callable$callbackany callable acceptable for call_user_func
Returns
void

Definition at line 209 of file Events.php.

References Xoops\Core\Events\toInternalEventName().

Here is the call graph for this function:

Xoops\Core\Events::getEvents ( )

getEvents - for debugging only, return list of event listeners

Returns
array of events and listeners

Definition at line 220 of file Events.php.

References Xoops\Core\Events\$eventListeners.

static Xoops\Core\Events::getInstance ( )
static
Xoops\Core\Events::hasListeners (   $eventName)

hasListeners - for debugging only, return list of event listeners

Parameters
type$eventNameevent name
Returns
boolean true if one or more listeners are registered for the event

Definition at line 231 of file Events.php.

References Xoops\Core\Events\toInternalEventName().

Here is the call graph for this function:

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.

Returns
void

Definition at line 78 of file Events.php.

References Xoops\Core\Events\setEvents(), and Xoops\Core\Events\setPreloads().

Here is the call graph for this function:

Xoops\Core\Events::setEvents ( )
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.

Returns
void

Definition at line 145 of file Events.php.

Referenced by Xoops\Core\Events\initializeListeners().

Here is the caller graph for this function:

Xoops\Core\Events::setPreloads ( )
protected

Get list of all available preload files

Returns
void

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().

Here is the call graph for this function:

Here is the caller graph for this function:

Xoops\Core\Events::toInternalEventName (   $eventName)
protected

toInternalEventName - convert event name to internal form i.e. core.include.common.end becomes coreincludecommonend

Parameters
string$eventNamethe event name
Returns
string converted name

Definition at line 196 of file Events.php.

Referenced by Xoops\Core\Events\addListener(), Xoops\Core\Events\hasListeners(), and Xoops\Core\Events\triggerEvent().

Here is the caller graph for this function:

Xoops\Core\Events::triggerEvent (   $eventName,
  $args = array() 
)

Trigger a specific event

Parameters
string$eventNameName of the event to trigger
mixed$argsMethod arguments
Returns
void

Definition at line 174 of file Events.php.

References Xoops\Core\Events\toInternalEventName().

Here is the call graph for this function:

Member Data Documentation

array $eventListeners Xoops\Core\Events::$eventListeners['eventname'][]=Closure = array()
protected

key is event name, value is array of callables

Definition at line 38 of file Events.php.

Referenced by Xoops\Core\Events\getEvents().

Xoops\Core\Events::$eventsEnabled = true
protected

bool $eventsEnabled

Definition at line 43 of file Events.php.

Xoops\Core\Events::$preloadList = array()
protected

Definition at line 32 of file Events.php.


The documentation for this class was generated from the following file: