Dispatcher
Implements DispatcherInterfaceImplementation of a DispatcherInterface supporting prioritized listeners.
| since |
1.0 |
|---|---|
| package |
Joomla Framework |
Methods
addEvent
Add an event to this dispatcher, only if it is not existing.
addEvent(\Joomla\Event\EventInterface event) :
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Arguments
- event
EventInterfaceThe event.
Response
$this
addListener
Attaches a listener to an event
addListener( eventName, Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 841 |Array callback, priority) :
| since |
1.0 |
|---|
Arguments
- eventName
stringThe event to listen to.- callback
callableA callable function- priority
intThe priority at which the $callback executed
Response
bool
addSubscriber
Adds an event subscriber.
addSubscriber(\Joomla\Event\SubscriberInterface subscriber) :
clearEvents
Clear all events.
clearEvents() : \Joomla\Event\EventInterface||string|int
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Response
array<string|int, EventInterface>The old events.
clearListeners
Clear the listeners in this dispatcher.
clearListeners( event = null) :
If an event is specified, the listeners will be cleared only for that event.
| since |
1.0 |
|---|
Arguments
- event
stringThe event name.
Response
$this
countEvents
Count the number of registered event.
countEvents() :
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Response
intThe number of registered events.
countListeners
Count the number of registered listeners for the given event.
countListeners( event) :
| since |
1.0 |
|---|
Arguments
- event
stringThe event name.
Response
int
dispatch
Dispatches an event to all registered listeners.
dispatch( name, \Joomla\Event\EventInterface event = null) : \Joomla\Event\EventInterface
| since |
2.0.0 |
|---|
Arguments
- name
stringThe name of the event to dispatch.- event
EventInterface|nullThe event to pass to the event handlers/listeners. If not supplied, an empty EventInterface instance is created. Note, not passing an event is deprecated and will be required as of 3.0.
Response
getDefaultEvent
Get an event object for the specified event name
getDefaultEvent( name) : \Joomla\Event\EventInterface
| since |
2.0.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Arguments
- name
stringThe event name to get an EventInterface object for
Response
getEvent
Get the event object identified by the given name.
getEvent( name, default = null) : \Joomla\Event\EventInterface|mixed
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Arguments
- name
stringThe event name.- default
mixedThe default value if the event was not registered.
Response
EventInterface|mixedThe event of the default value.
getEvents
Get the registered events.
getEvents() : \Joomla\Event\EventInterface||string|int
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Response
array<string|int, EventInterface>The registered event.
getListenerPriority
Get the priority of the given listener for the given event.
getListenerPriority( eventName, Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 841 |Array callback) :
| since |
1.0 |
|---|
Arguments
- eventName
stringThe event to listen to.- callback
callableA callable function
Response
mixedThe listener priority or null if the listener doesn't exist.
getListeners
Get the listeners registered to the given event.
getListeners(string|null event = null) : callable||string|int
| since |
1.0 |
|---|
Arguments
- event
string|nullThe event to fetch listeners for or null to fetch all listeners
Response
array<string|int, callable>An array of registered listeners sorted according to their priorities.
hasEvent
Tell if the given event has been added to this dispatcher.
hasEvent(\Joomla\Event\EventInterface|string event) :
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Arguments
- event
EventInterface|stringThe event object or name.
Response
boolTrue if the listener has the given event, false otherwise.
hasListener
Tell if the given listener has been added.
hasListener( Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 841 |Array callback, string eventName = null) :
If an event is specified, it will tell if the listener is registered for that event.
| since |
1.0 |
|---|
Arguments
- callback
callableThe callable to check is listening to the event.- eventName
string|nullAn optional event name to check a listener is subscribed to.
Response
boolTrue if the listener is registered, false otherwise.
removeEvent
Remove an event from this dispatcher. The registered listeners will remain.
removeEvent(\Joomla\Event\EventInterface|string event) :
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Arguments
- event
EventInterface|stringThe event object or name.
Response
$this
removeListener
Removes an event listener from the specified event.
removeListener( eventName, Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 841 |Array listener) :
| since |
2.0.0 |
|---|
Arguments
- eventName
stringThe event to remove a listener from.- listener
callableThe listener to remove.
Response
void
removeSubscriber
Removes an event subscriber.
removeSubscriber(\Joomla\Event\SubscriberInterface subscriber) :
setEvent
Set an event to the dispatcher. It will replace any event with the same name.
setEvent(\Joomla\Event\EventInterface event) :
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Arguments
- event
EventInterfaceThe event.
Response
$this
triggerEvent
Trigger an event.
triggerEvent(\Joomla\Event\EventInterface|string event) : \Joomla\Event\EventInterface
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Use dispatch() instead. |
Arguments
- event
EventInterface|stringThe event object or name.
Response
EventInterfaceThe event after being passed through all listeners.
Properties
events
An array of registered events indexed by the event names.
| since |
1.0 |
|---|---|
| deprecated |
2.0 will be removed in 5.0 Default event objects will no longer be supported |
Type(s)
array<string|int, EventInterface>
listeners
An array of ListenersPriorityQueue indexed by the event names.
| since |
1.0 |
|---|
Type(s)
array<string|int, ListenersPriorityQueue>