SystemEvents extends AppModel
Events model
Table of Contents
Methods
| __construct() | Initialize language |
| getObservers() | Retrieves all observers matching the given event |
| register() | Adds an observer to an event |
| trigger() | Triggers the given event on all observers |
| unregister() | Removes the event and all observers, or a specific observer |
| getObserverInstance() | Retrieves an instance of the observer |
| isCallableObserver() | Determines whether the given observer is callable |
Methods
__construct()
Initialize language
public
__construct() : mixed
getObservers()
Retrieves all observers matching the given event
public
getObservers(string $event) : array<string|int, mixed>
Parameters
- $event : string
-
The name of the event
Return values
array<string|int, mixed> —An array of all matching observers
register()
Adds an observer to an event
public
register(array<string|int, mixed> $vars) : mixed
Parameters
- $vars : array<string|int, mixed>
-
System event information, including:
- event The name of the event
- observer The name of the observer
trigger()
Triggers the given event on all observers
public
trigger(EventInterface $event) : EventInterface
Parameters
- $event : EventInterface
-
The event being triggered
Return values
EventInterface —The processed event object
unregister()
Removes the event and all observers, or a specific observer
public
unregister(string $event[, string $observer = null ]) : mixed
Parameters
- $event : string
-
The name of the event to delete
- $observer : string = null
-
The fully-qualified name of the observer, including namespace
getObserverInstance()
Retrieves an instance of the observer
private
getObserverInstance(string $observer) : bool|Observable
Parameters
- $observer : string
-
The namespace of the observer class, or the full system path
Return values
bool|Observable —An instance of the observer if available, otherwise false
isCallableObserver()
Determines whether the given observer is callable
private
isCallableObserver(string $observer) : bool
Parameters
- $observer : string
-
The observer
Return values
bool —True if the observer is callable, or false otherwise