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) : $this
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Arguments
- event
\Joomla\Event\EventInterface
The event.
Response
$this
addListener
Attaches a listener to an event
addListener(string eventName, callable callback, int priority) : bool
since |
1.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.
clearEvents
Clear all events.
clearEvents() : \Joomla\Event\EventInterface[]
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Response
\Joomla\Event\EventInterface[]
The old events.
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 |
1.0 |
---|
Arguments
- event
string
The event name.
Response
$this
countEvents
Count the number of registered event.
countEvents() : int
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Response
int
The numer of registered events.
countListeners
Count the number of registered listeners for the given event.
countListeners(string event) : int
since |
1.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
getDefaultEvent
Get an event object for the specified event name
getDefaultEvent(string name) : \Joomla\Event\EventInterface
since |
2.0.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Arguments
- name
string
The event name to get an EventInterface object for
Response
\Joomla\Event\EventInterface
getEvent
Get the event object identified by the given name.
getEvent(string name, mixed default = null) : \Joomla\Event\EventInterface|mixed
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Arguments
- name
string
The event name.- default
mixed
The default value if the event was not registered.
Response
\Joomla\Event\EventInterface|mixed
The event of the default value.
getEvents
Get the registered events.
getEvents() : \Joomla\Event\EventInterface[]
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Response
\Joomla\Event\EventInterface[]
The registered event.
getListenerPriority
Get the priority of the given listener for the given event.
getListenerPriority(string eventName, callable callback) : mixed
since |
1.0 |
---|
Arguments
- eventName
string
The event to listen to.- callback
callable
A callable function
Response
mixed
The 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[]
since |
1.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.
hasEvent
Tell if the given event has been added to this dispatcher.
hasEvent(\Joomla\Event\EventInterface|string event) : bool
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Arguments
- event
\Joomla\Event\EventInterface|string
The event object or name.
Response
bool
True if the listener has the given event, false otherwise.
hasListener
Tell if the given listener has been added.
hasListener(callable callback, string eventName = null) : bool
If an event is specified, it will tell if the listener is registered for that event.
since |
1.0 |
---|
Arguments
- callback
callable
The callable to check is listening to the event.- eventName
string
An optional event name to check a listener is subscribed to.
Response
bool
True 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) : $this
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Arguments
- event
\Joomla\Event\EventInterface|string
The event object or name.
Response
$this
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.
setEvent
Set an event to the dispatcher. It will replace any event with the same name.
setEvent(\Joomla\Event\EventInterface event) : $this
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Arguments
- event
\Joomla\Event\EventInterface
The event.
Response
$this
triggerEvent
Trigger an event.
triggerEvent(\Joomla\Event\EventInterface|string event) : \Joomla\Event\EventInterface
since |
1.0 |
---|---|
deprecated |
3.0 Use dispatch() instead. |
Arguments
- event
\Joomla\Event\EventInterface|string
The event object or name.
Response
\Joomla\Event\EventInterface
The event after being passed through all listeners.
Properties
events
An array of registered events indexed by the event names.
since |
1.0 |
---|---|
deprecated |
3.0 Default event objects will no longer be supported |
Type(s)
\Joomla\Event\EventInterface[]
listeners
An array of ListenersPriorityQueue indexed by the event names.
since |
1.0 |
---|
Type(s)
\Joomla\Event\ListenersPriorityQueue[]