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
string
The event to listen to.- callback
callable
A callable function.- priority
int
The 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\SubscriberInterface
The 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
string
The 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
string
The 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
string
The name of the event to dispatch.- event
\Joomla\Event\EventInterface
The 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|null
The 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
callable
The callable to check is listening to the event.- eventName
string|null
An optional event name to check a listener is subscribed to.
Response
bool
True 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
string
The event to remove a listener from.- listener
callable
The listener to remove.
removeSubscriber
Removes an event subscriber.
removeSubscriber(\Joomla\Event\SubscriberInterface subscriber) : void
since |
2.0.0 |
---|
Arguments
- subscriber
\Joomla\Event\SubscriberInterface
The subscriber.