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) : \Joomla\Event\Dispatcher
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterfaceThe event.
Response
\Joomla\Event\DispatcherThis method is chainable.
addListener
Add a listener to this dispatcher, only if not already registered to these events.
addListener(object|\Closure listener, array events = array()) : \Joomla\Event\Dispatcher
If no events are specified, it will be registered to all events matching it's methods name. In the case of a closure, you must specify at least one event name.
| throws |
|
|---|---|
| since |
1.0 |
Arguments
- listener
object|\ClosureThe listener- events
arrayAn associative array of event names as keys and the corresponding listener priority as values.
Response
\Joomla\Event\DispatcherThis method is chainable.
clearEvents
Clear all events.
clearEvents() : \Joomla\Event\EventInterface[]
| since |
1.0 |
|---|
Response
\Joomla\Event\EventInterface[]The old events.
clearListeners
Clear the listeners in this dispatcher.
clearListeners(\Joomla\Event\EventInterface|string event = null) : \Joomla\Event\Dispatcher
If an event is specified, the listeners will be cleared only for that event.
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
\Joomla\Event\DispatcherThis method is chainable.
countEvents
Count the number of registered event.
countEvents() : int
| since |
1.0 |
|---|
Response
intThe numer of registered events.
countListeners
Count the number of registered listeners for the given event.
countListeners(\Joomla\Event\EventInterface|string event) : int
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
intThe number of registered listeners for the given event.
getEvent
Get the event object identified by the given name.
getEvent(string name, mixed default = null) : \Joomla\Event\EventInterface|mixed
| since |
1.0 |
|---|
Arguments
- name
stringThe event name.- default
mixedThe default value if the event was not registered.
Response
\Joomla\Event\EventInterface|mixedThe event of the default value.
getEvents
Get the registered events.
getEvents() : \Joomla\Event\EventInterface[]
| since |
1.0 |
|---|
Response
\Joomla\Event\EventInterface[]The registered event.
getListenerPriority
Get the priority of the given listener for the given event.
getListenerPriority(object|\Closure listener, \Joomla\Event\EventInterface|string event) : mixed
| since |
1.0 |
|---|
Arguments
- listener
object|\ClosureThe listener.- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
mixedThe listener priority or null if the listener doesn't exist.
getListeners
Get the listeners registered to the given event.
getListeners(\Joomla\Event\EventInterface|string event) : object[]
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
object[]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 |
|---|
Arguments
- event
\Joomla\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(object|\Closure listener, \Joomla\Event\EventInterface|string event = null) : bool
If an event is specified, it will tell if the listener is registered for that event.
| since |
1.0 |
|---|
Arguments
- listener
object|\ClosureThe listener.- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
boolTrue if the listener is registered, false otherwise.
removeEvent
Remove an event from this dispatcher.
removeEvent(\Joomla\Event\EventInterface|string event) : \Joomla\Event\Dispatcher
The registered listeners will remain.
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
\Joomla\Event\DispatcherThis method is chainable.
removeListener
Remove the given listener from this dispatcher.
removeListener(object|\Closure listener, \Joomla\Event\EventInterface|string event = null) : \Joomla\Event\Dispatcher
If no event is specified, it will be removed from all events it is listening to.
| since |
1.0 |
|---|
Arguments
- listener
object|\ClosureThe listener to remove.- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
\Joomla\Event\DispatcherThis method is chainable.
setEvent
Set an event to the dispatcher.
setEvent(\Joomla\Event\EventInterface event) : \Joomla\Event\Dispatcher
It will replace any event with the same name.
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterfaceThe event.
Response
\Joomla\Event\DispatcherThis method is chainable.
setListenerFilter
Sets a regular expression to filter the class methods when adding a listener.
setListenerFilter(string regex) : \Joomla\Event\Dispatcher
| since |
1.0 |
|---|---|
| deprecated |
1.1.0 Incorporate a method in your listener object such as |
Arguments
- regex
stringA regular expression (for example '^on' will only register methods starting with "on").
Response
\Joomla\Event\DispatcherThis method is chainable.
triggerEvent
Trigger an event.
triggerEvent(\Joomla\Event\EventInterface|string event) : \Joomla\Event\EventInterface
| since |
1.0 |
|---|
Arguments
- event
\Joomla\Event\EventInterface|stringThe event object or name.
Response
\Joomla\Event\EventInterfaceThe event after being passed through all listeners.
Properties
events
An array of registered events indexed by the event names.
| since |
1.0 |
|---|
Type(s)
\Joomla\Event\EventInterface[]
listenerFilter
A regular expression that will filter listener method names.
| since |
1.0 |
|---|---|
| deprecated |
1.1.0 |
Type(s)
string
listeners
An array of ListenersPriorityQueue indexed by the event names.
| since |
1.0 |
|---|
Type(s)
\Joomla\Event\ListenersPriorityQueue[]