Implementation of a DispatcherInterface supporting prioritized listeners.
- Depuis
- 1.0
◆ addEvent()
◆ addListener()
addListener |
( |
|
$listener, |
|
|
array |
$events = array() |
|
) |
| |
Add a listener to this dispatcher, only if not already registered to these events. 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.
- Paramètres
-
object | Closure | $listener | The listener |
array | $events | An associative array of event names as keys and the corresponding listener priority as values. |
- Renvoie
- Dispatcher This method is chainable.
- Exceptions
-
- Depuis
- 1.0
Références Dispatcher\$events, $name, ListenersPriorityQueue\add(), et Priority\NORMAL.
◆ clearEvents()
◆ clearListeners()
clearListeners |
( |
|
$event = null | ) |
|
Clear the listeners in this dispatcher. If an event is specified, the listeners will be cleared only for that event.
- Paramètres
-
- Renvoie
- Dispatcher This method is chainable.
- Depuis
- 1.0
◆ countEvents()
Count the number of registered event.
- Renvoie
- integer The numer of registered events.
- Depuis
- 1.0
◆ countListeners()
Count the number of registered listeners for the given event.
- Paramètres
-
- Renvoie
- integer The number of registered listeners for the given event.
- Depuis
- 1.0
◆ getEvent()
getEvent |
( |
|
$name, |
|
|
|
$default = null |
|
) |
| |
Get the event object identified by the given name.
- Paramètres
-
string | $name | The event name. |
mixed | $default | The default value if the event was not registered. |
- Renvoie
- EventInterface|mixed The event of the default value.
- Depuis
- 1.0
Références $default, et $name.
◆ getEvents()
◆ getListenerPriority()
getListenerPriority |
( |
|
$listener, |
|
|
|
$event |
|
) |
| |
Get the priority of the given listener for the given event.
- Paramètres
-
object | Closure | $listener | The listener. |
EventInterface | string | $event | The event object or name. |
- Renvoie
- mixed The listener priority or null if the listener doesn't exist.
- Depuis
- 1.0
◆ getListeners()
Get the listeners registered to the given event.
- Paramètres
-
- Renvoie
- object[] An array of registered listeners sorted according to their priorities.
- Depuis
- 1.0
◆ hasEvent()
Tell if the given event has been added to this dispatcher.
- Paramètres
-
- Renvoie
- boolean True if the listener has the given event, false otherwise.
- Depuis
- 1.0
◆ hasListener()
hasListener |
( |
|
$listener, |
|
|
|
$event = null |
|
) |
| |
Tell if the given listener has been added. If an event is specified, it will tell if the listener is registered for that event.
- Paramètres
-
object | Closure | $listener | The listener. |
EventInterface | string | $event | The event object or name. |
- Renvoie
- boolean True if the listener is registered, false otherwise.
- Depuis
- 1.0
◆ removeEvent()
Remove an event from this dispatcher. The registered listeners will remain.
- Paramètres
-
- Renvoie
- Dispatcher This method is chainable.
- Depuis
- 1.0
◆ removeListener()
removeListener |
( |
|
$listener, |
|
|
|
$event = null |
|
) |
| |
Remove the given listener from this dispatcher. If no event is specified, it will be removed from all events it is listening to.
- Paramètres
-
object | Closure | $listener | The listener to remove. |
EventInterface | string | $event | The event object or name. |
- Renvoie
- Dispatcher This method is chainable.
- Depuis
- 1.0
◆ setEvent()
Set an event to the dispatcher. It will replace any event with the same name.
- Paramètres
-
- Renvoie
- Dispatcher This method is chainable.
- Depuis
- 1.0
Références EventInterface\getName().
◆ setListenerFilter()
setListenerFilter |
( |
|
$regex | ) |
|
Sets a regular expression to filter the class methods when adding a listener.
- Paramètres
-
string | $regex | A regular expression (for example '^on' will only register methods starting with "on"). |
- Renvoie
- Dispatcher This method is chainable.
- Depuis
- 1.0
- Obsolète:
- 1.1.0 Incorporate a method in your listener object such as
getEvents
to feed into the setListener
method.
◆ triggerEvent()
◆ $events
◆ $listenerFilter
◆ $listeners
La documentation de cette classe a été générée à partir du fichier suivant :