EventAware
Trait for application classes which dispatch events
| since |
4.0.0 |
|---|---|
| package |
Joomla CMS |
Methods
getDispatcher
Get the event dispatcher.
getDispatcher() : \Joomla\Event\DispatcherInterface
| since |
4.0.0 |
|---|---|
| throws |
|
Response
DispatcherInterface
getEventClassByEventName
Get the concrete event class name for the given event name.
getEventClassByEventName( eventName) :
This method falls back to the generic Joomla\Event\Event class if the event name is unknown to this trait.
| since |
4.2.0 |
|---|
Arguments
- eventName
stringThe event name
Response
stringThe event class name
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
| since |
4.0.0 |
|---|
Response
LoggerInterface
registerEvent
Registers a handler to a particular event group.
registerEvent( event, Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 841 |Array handler) :
| since |
4.0.0 |
|---|
Arguments
- event
stringThe event name.- handler
callableThe handler, a function or an instance of an event object.
Response
$this
triggerEvent
Calls all handlers associated with an event group.
triggerEvent( eventName, array|\Joomla\Event\Event args = []) : mixed||string|int
This is a legacy method, implementing old-style (Joomla! 3.x) plugin calls. It's best to go directly through the Dispatcher and handle the returned EventInterface object instead of going through this method. This method is deprecated and will be removed in Joomla! 5.x.
This method will only return the 'result' argument of the event
| since |
4.0.0 |
|---|---|
| throws |
|
| deprecated |
4.0 will be removed in 7.0 Use the Dispatcher method instead Example: Factory::getApplication()->getDispatcher()->dispatch($eventName, $event); |
Arguments
- eventName
stringThe event name.- args
array<string|int, mixed>|EventAn array of arguments or an Event object (optional).
Response
array<string|int, mixed>An array of results from each function call. Note this will be an empty array if no dispatcher is set.
Properties
eventNameToConcreteClass
Maps event names to concrete Event classes.
This is only for events with invariable names. Events with variable names are handled with PHP logic in the getEventClassByEventName class.
| since |
4.2.0 |
|---|
Type(s)
array<string|int, mixed>