| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <fabien@symfony.com> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* The EventDispatcherInterface is the central point of Symfony's event listener system. |
| 14 |
* Listeners are registered on the manager and events are dispatched through the |
| 15 |
* manager. |
| 16 |
* |
| 17 |
* @author Bernhard Schussek <bschussek@gmail.com> |
| 18 |
* |
| 19 |
* @api |
| 20 |
*/ |
| 21 |
interface Symfony_EventDispatcher_EventDispatcherInterface |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Dispatches an event to all registered listeners. |
| 25 |
* |
| 26 |
* @param string $eventName The name of the event to dispatch. The name of |
| 27 |
* the event is the name of the method that is |
| 28 |
* invoked on listeners. |
| 29 |
* @param Symfony_EventDispatcher_Event $event The event to pass to the event handlers/listeners. |
| 30 |
* If not supplied, an empty Event instance is created. |
| 31 |
* |
| 32 |
* @return Symfony_EventDispatcher_Event |
| 33 |
* |
| 34 |
* @api |
| 35 |
*/ |
| 36 |
public function dispatch($eventName, Symfony_EventDispatcher_Event $event = null); |
| 37 |
|
| 38 |
/** |
| 39 |
* Adds an event listener that listens on the specified events. |
| 40 |
* |
| 41 |
* @param string $eventName The event to listen on |
| 42 |
* @param callable $listener The listener |
| 43 |
* @param int $priority The higher this value, the earlier an event |
| 44 |
* listener will be triggered in the chain (defaults to 0) |
| 45 |
* |
| 46 |
* @api |
| 47 |
*/ |
| 48 |
public function addListener($eventName, $listener, $priority = 0); |
| 49 |
|
| 50 |
/** |
| 51 |
* Adds an event subscriber. |
| 52 |
* |
| 53 |
* The subscriber is asked for all the events he is |
| 54 |
* interested in and added as a listener for these events. |
| 55 |
* |
| 56 |
* @param Symfony_EventDispatcher_EventSubscriberInterface $subscriber The subscriber. |
| 57 |
* |
| 58 |
* @api |
| 59 |
*/ |
| 60 |
public function addSubscriber(Symfony_EventDispatcher_EventSubscriberInterface $subscriber); |
| 61 |
|
| 62 |
/** |
| 63 |
* Removes an event listener from the specified events. |
| 64 |
* |
| 65 |
* @param string $eventName The event to remove a listener from |
| 66 |
* @param callable $listener The listener to remove |
| 67 |
*/ |
| 68 |
public function removeListener($eventName, $listener); |
| 69 |
|
| 70 |
/** |
| 71 |
* Removes an event subscriber. |
| 72 |
* |
| 73 |
* @param Symfony_EventDispatcher_EventSubscriberInterface $subscriber The subscriber |
| 74 |
*/ |
| 75 |
public function removeSubscriber(Symfony_EventDispatcher_EventSubscriberInterface $subscriber); |
| 76 |
|
| 77 |
/** |
| 78 |
* Gets the listeners of a specific event or all listeners. |
| 79 |
* |
| 80 |
* @param string $eventName The name of the event |
| 81 |
* |
| 82 |
* @return array The event listeners for the specified event, or all event listeners by event name |
| 83 |
*/ |
| 84 |
public function getListeners($eventName = null); |
| 85 |
|
| 86 |
/** |
| 87 |
* Checks whether an event has any registered listeners. |
| 88 |
* |
| 89 |
* @param string $eventName The name of the event |
| 90 |
* |
| 91 |
* @return bool true if the specified event has any listeners, false otherwise |
| 92 |
*/ |
| 93 |
public function hasListeners($eventName = null); |
| 94 |
} |
| 95 |
|