DispatcherInterface
Interface for event dispatchers.
| since |
1.0 |
|---|---|
| package |
Joomla Framework |
Methods
addListener
Attaches a listener to an event
addListener(string eventName, callable callback, int priority) : bool
| since |
2.0.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) : void
| since |
2.0.0 |
|---|
Arguments
- subscriber
\Joomla\Event\SubscriberInterfaceThe subscriber.
clearListeners
Clear the listeners in this dispatcher.
clearListeners(string event = null) : $this
If an event is specified, the listeners will be cleared only for that event.
| since |
2.0.0 |
|---|
Arguments
- event
stringThe event name.
Response
$this
countListeners
Count the number of registered listeners for the given event.
countListeners(string event) : int
| since |
2.0.0 |
|---|
Arguments
- event
stringThe event name.
Response
int
dispatch
Dispatches an event to all registered listeners.
dispatch(string name, \Joomla\Event\EventInterface event = null) : \Joomla\Event\EventInterface
| since |
2.0.0 |
|---|
Arguments
- name
stringThe name of the event to dispatch.- event
\Joomla\Event\EventInterfaceThe 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
\Joomla\Event\EventInterface
getListeners
Get the listeners registered to the given event.
getListeners(string|null event = null) : callable[]
| since |
2.0.0 |
|---|
Arguments
- event
string|nullThe event to fetch listeners for or null to fetch all listeners
Response
callable[]An array of registered listeners sorted according to their priorities.
hasListener
Tell if the given listener has been added.
hasListener(callable callback, string|null eventName = null) : bool
If an event is specified, it will tell if the listener is registered for that event.
| since |
2.0.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.
removeListener
Removes an event listener from the specified event.
removeListener(string eventName, callable listener) : void
| since |
2.0.0 |
|---|
Arguments
- eventName
stringThe event to remove a listener from.- listener
callableThe listener to remove.
removeSubscriber
Removes an event subscriber.
removeSubscriber(\Joomla\Event\SubscriberInterface subscriber) : void
| since |
2.0.0 |
|---|
Arguments
- subscriber
\Joomla\Event\SubscriberInterfaceThe subscriber.