Elgg
Version 6.1
|
Events service. More...
Public Member Functions | |
__construct (protected HandlersService $handlers) | |
Constructor. More... | |
trigger (string $name, string $type, $object=null, array $options=[]) | |
Triggers an Elgg event. More... | |
triggerResults (string $name, string $type, array $params=[], $value=null, array $options=[]) | |
Triggers a event that is allowed to return a mixed result. More... | |
triggerBefore (string $name, string $type, $object=null, array $options=[]) | |
Trigger a "Before event" indicating a process is about to begin. More... | |
triggerAfter (string $name, string $type, $object=null, array $options=[]) | |
Trigger an "After event" indicating a process has finished. More... | |
triggerSequence (string $name, string $type, $object=null, callable $callable=null, array $options=[]) | |
Trigger a sequence of <event>:before, <event>, and <event>:after handlers. More... | |
triggerResultsSequence (string $name, string $type, array $params=[], $value=null, callable $callable=null, array $options=[]) | |
Trigger an sequence of <event>:before, <event>, and <event>:after handlers. More... | |
triggerDeprecated (string $name, string $type, $object=null, string $message= '', string $version= '', array $options=[]) | |
Trigger an event sequence normally, but send a notice about deprecated use if any handlers are registered. More... | |
triggerDeprecatedResults (string $name, string $type, array $params=[], $returnvalue=null, string $message= '', string $version= '', array $options=[]) | |
Trigger an event sequence normally, but send a notice about deprecated use if any handlers are registered. More... | |
registerHandler (string $name, string $type, $callback, int $priority=500) | |
Register a callback as a event handler. More... | |
unregisterHandler (string $name, string $type, $callback) | |
Unregister a callback as an event handler. More... | |
clearHandlers (string $name, string $type) | |
Clears all callback registrations for an event. More... | |
getAllHandlers () | |
Returns all registered handlers as array( $name => array( $type => array( $priority => array( callback, callback, ) ) ) More... | |
hasHandler (string $name, string $type) | |
Is a handler registered for this specific name and type? "all" handlers are not considered. More... | |
getOrderedHandlers (string $name, string $type) | |
Returns an ordered array of handlers registered for $name and $type. More... | |
backup () | |
Temporarily remove all event registrations (before tests) More... | |
restore () | |
Restore backed up event registrations (after tests) More... | |
Public Attributes | |
const | REG_KEY_PRIORITY = 0 |
const | REG_KEY_INDEX = 1 |
const | REG_KEY_HANDLER = 2 |
const | OPTION_STOPPABLE = 'stoppable' |
const | OPTION_USE_TIMER = 'use_timer' |
const | OPTION_TIMER_KEYS = 'timer_keys' |
const | OPTION_BEGIN_CALLBACK = 'begin_callback' |
const | OPTION_END_CALLBACK = 'end_callback' |
Protected Member Functions | |
getMatcher ($spec) | |
Create a matcher for the given callable (if it's for a static or dynamic method) More... | |
checkDeprecation (string $name, string $type, string $message, string $version) | |
Check if handlers are registered on a deprecated event. More... | |
callHandler ($callable, $event, array $args, array $options=[]) | |
Protected Attributes | |
int | $next_index = 0 |
array | $ordered_handlers_cache = [] |
array | $registrations = [] |
array | $backups = [] |
Elgg\EventsService::__construct | ( | protected HandlersService | $handlers | ) |
Constructor.
HandlersService | $handlers | Handlers |
Definition at line 46 of file EventsService.php.
Elgg\EventsService::backup | ( | ) |
|
protected |
callable | $callable | Callable |
mixed | $event | Event object |
array | $args | Event arguments |
array | $options | (internal) options for triggering the event |
Definition at line 572 of file EventsService.php.
|
protected |
Check if handlers are registered on a deprecated event.
If so Display a message
string | $name | the name of the event |
string | $type | the type of the event |
string | $message | The deprecation message |
string | $version | Human-readable release version: 1.9, 1.10, ... |
Definition at line 551 of file EventsService.php.
Elgg\EventsService::clearHandlers | ( | string | $name, |
string | $type | ||
) |
Clears all callback registrations for an event.
string | $name | The name of the event |
string | $type | The type of the event |
Definition at line 388 of file EventsService.php.
Elgg\EventsService::getAllHandlers | ( | ) |
Returns all registered handlers as array( $name => array( $type => array( $priority => array( callback, callback, ) ) )
Definition at line 407 of file EventsService.php.
|
protected |
Create a matcher for the given callable (if it's for a static or dynamic method)
callable | $spec | Callable we're creating a matcher for |
Definition at line 491 of file EventsService.php.
Elgg\EventsService::getOrderedHandlers | ( | string | $name, |
string | $type | ||
) |
Returns an ordered array of handlers registered for $name and $type.
string | $name | The name of the event |
string | $type | The type of the event |
Definition at line 443 of file EventsService.php.
Elgg\EventsService::hasHandler | ( | string | $name, |
string | $type | ||
) |
Is a handler registered for this specific name and type? "all" handlers are not considered.
If you need to consider "all" handlers, you must check them independently, or use (bool) elgg()->events->getOrderedHandlers().
string | $name | The name of the event |
string | $type | The type of the event |
Definition at line 431 of file EventsService.php.
Elgg\EventsService::registerHandler | ( | string | $name, |
string | $type, | ||
$callback, | |||
int | $priority = 500 |
||
) |
Register a callback as a event handler.
string | $name | The name of the event |
string | $type | The type of the event |
callable | $callback | The name of a valid function or an array with object and method |
int | $priority | The priority - 500 is default, lower numbers called first |
Definition at line 324 of file EventsService.php.
Elgg\EventsService::restore | ( | ) |
Restore backed up event registrations (after tests)
Definition at line 532 of file EventsService.php.
Elgg\EventsService::trigger | ( | string | $name, |
string | $type, | ||
$object = null , |
|||
array | $options = [] |
||
) |
Triggers an Elgg event.
string | $name | The event name |
string | $type | The event type |
mixed | $object | The object involved in the event |
array | $options | (internal) options for triggering the event |
Definition at line 63 of file EventsService.php.
Elgg\EventsService::triggerAfter | ( | string | $name, |
string | $type, | ||
$object = null , |
|||
array | $options = [] |
||
) |
Trigger an "After event" indicating a process has finished.
Unlike regular events, all the handlers will be called, their return values ignored.
To register for an after event, append ":after" to the event name when registering.
string | $name | The event name. The fired event type will be appended with ":after". |
string | $type | The event type |
mixed | $object | The object involved in the event |
array | $options | (internal) options for triggering the event |
Definition at line 184 of file EventsService.php.
Elgg\EventsService::triggerBefore | ( | string | $name, |
string | $type, | ||
$object = null , |
|||
array | $options = [] |
||
) |
Trigger a "Before event" indicating a process is about to begin.
Like regular events, a handler returning false will cancel the process and false will be returned.
To register for a before event, append ":before" to the event name when registering.
string | $name | The event type. The fired event type will be appended with ":before". |
string | $type | The object type |
mixed | $object | The object involved in the event |
array | $options | (internal) options for triggering the event |
Definition at line 162 of file EventsService.php.
Elgg\EventsService::triggerDeprecated | ( | string | $name, |
string | $type, | ||
$object = null , |
|||
string | $message = '' , |
||
string | $version = '' , |
||
array | $options = [] |
||
) |
Trigger an event sequence normally, but send a notice about deprecated use if any handlers are registered.
string | $name | The event name |
string | $type | The event type |
mixed | $object | The object involved in the event |
string | $message | The deprecation message |
string | $version | Human-readable release version: 1.9, 1.10, ... |
array | $options | (internal) options for triggering the event |
Definition at line 282 of file EventsService.php.
Elgg\EventsService::triggerDeprecatedResults | ( | string | $name, |
string | $type, | ||
array | $params = [] , |
||
$returnvalue = null , |
|||
string | $message = '' , |
||
string | $version = '' , |
||
array | $options = [] |
||
) |
Trigger an event sequence normally, but send a notice about deprecated use if any handlers are registered.
string | $name | The event name |
string | $type | The event type |
array | $params | The parameters related to the event |
mixed | $returnvalue | The return value |
string | $message | The deprecation message |
string | $version | Human-readable release version: 1.9, 1.10, ... |
array | $options | (internal) options for triggering the event |
Definition at line 304 of file EventsService.php.
Elgg\EventsService::triggerResults | ( | string | $name, |
string | $type, | ||
array | $params = [] , |
||
$value = null , |
|||
array | $options = [] |
||
) |
Triggers a event that is allowed to return a mixed result.
string | $name | The name of the event |
string | $type | The type of the event |
mixed | $params | Supplied params for the event |
mixed | $value | The value of the event, this can be altered by registered callbacks |
array | $options | (internal) options for triggering the event |
Definition at line 119 of file EventsService.php.
Elgg\EventsService::triggerResultsSequence | ( | string | $name, |
string | $type, | ||
array | $params = [] , |
||
$value = null , |
|||
callable | $callable = null , |
||
array | $options = [] |
||
) |
Trigger an sequence of <event>:before, <event>, and <event>:after handlers.
Allows <event>:before to terminate the sequence by returning false from a handler Allows running a callable on successful <event> before <event>:after is triggered
string | $name | The event name |
string | $type | The event type |
mixed | $params | Supplied params for the event |
mixed | $value | The value of the event, this can be altered by registered callbacks |
callable | $callable | Callable to run on successful event, before event:after |
array | $options | (internal) options for triggering the event |
Definition at line 242 of file EventsService.php.
Elgg\EventsService::triggerSequence | ( | string | $name, |
string | $type, | ||
$object = null , |
|||
callable | $callable = null , |
||
array | $options = [] |
||
) |
Trigger a sequence of <event>:before, <event>, and <event>:after handlers.
Allows <event>:before to terminate the sequence by returning false from a handler Allows running a callable on successful <event> before <event>:after is triggered Returns the result of the callable or bool
string | $name | The event name |
string | $type | The event type |
mixed | $object | The object involved in the event |
callable | $callable | Callable to run on successful event, before event:after |
array | $options | (internal) options for triggering the event |
Definition at line 204 of file EventsService.php.
Elgg\EventsService::unregisterHandler | ( | string | $name, |
string | $type, | ||
$callback | |||
) |
Unregister a callback as an event handler.
string | $name | The name of the event |
string | $type | The name of the type of entity (eg "user", "object" etc) |
callable | $callback | The PHP callback to be removed. Since 1.11, static method callbacks will match dynamic methods |
Definition at line 357 of file EventsService.php.
|
protected |
Definition at line 39 of file EventsService.php.
|
protected |
Definition at line 30 of file EventsService.php.
|
protected |
Definition at line 32 of file EventsService.php.
|
protected |
Definition at line 37 of file EventsService.php.
const Elgg\EventsService::OPTION_BEGIN_CALLBACK = 'begin_callback' |
Definition at line 27 of file EventsService.php.
const Elgg\EventsService::OPTION_END_CALLBACK = 'end_callback' |
Definition at line 28 of file EventsService.php.
const Elgg\EventsService::OPTION_STOPPABLE = 'stoppable' |
Definition at line 24 of file EventsService.php.
const Elgg\EventsService::OPTION_TIMER_KEYS = 'timer_keys' |
Definition at line 26 of file EventsService.php.
const Elgg\EventsService::OPTION_USE_TIMER = 'use_timer' |
Definition at line 25 of file EventsService.php.
const Elgg\EventsService::REG_KEY_HANDLER = 2 |
Definition at line 22 of file EventsService.php.
const Elgg\EventsService::REG_KEY_INDEX = 1 |
Definition at line 21 of file EventsService.php.
const Elgg\EventsService::REG_KEY_PRIORITY = 0 |
Definition at line 20 of file EventsService.php.