| 3 |
liveuser |
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 |
namespace Symfony\Component\EventDispatcher;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* The EventDispatcherInterface is the central point of Symfony's event listener system.
|
|
|
16 |
* Listeners are registered on the manager and events are dispatched through the
|
|
|
17 |
* manager.
|
|
|
18 |
*
|
|
|
19 |
* @author Bernhard Schussek <bschussek@gmail.com>
|
|
|
20 |
*/
|
|
|
21 |
interface 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 Event $event The event to pass to the event handlers/listeners
|
|
|
30 |
* If not supplied, an empty Event instance is created.
|
|
|
31 |
*
|
|
|
32 |
* @return Event
|
|
|
33 |
*/
|
|
|
34 |
public function dispatch($eventName, Event $event = null);
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Adds an event listener that listens on the specified events.
|
|
|
38 |
*
|
|
|
39 |
* @param string $eventName The event to listen on
|
|
|
40 |
* @param callable $listener The listener
|
|
|
41 |
* @param int $priority The higher this value, the earlier an event
|
|
|
42 |
* listener will be triggered in the chain (defaults to 0)
|
|
|
43 |
*/
|
|
|
44 |
public function addListener($eventName, $listener, $priority = 0);
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Adds an event subscriber.
|
|
|
48 |
*
|
|
|
49 |
* The subscriber is asked for all the events he is
|
|
|
50 |
* interested in and added as a listener for these events.
|
|
|
51 |
*
|
|
|
52 |
* @param EventSubscriberInterface $subscriber The subscriber
|
|
|
53 |
*/
|
|
|
54 |
public function addSubscriber(EventSubscriberInterface $subscriber);
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Removes an event listener from the specified events.
|
|
|
58 |
*
|
|
|
59 |
* @param string $eventName The event to remove a listener from
|
|
|
60 |
* @param callable $listener The listener to remove
|
|
|
61 |
*/
|
|
|
62 |
public function removeListener($eventName, $listener);
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Removes an event subscriber.
|
|
|
66 |
*
|
|
|
67 |
* @param EventSubscriberInterface $subscriber The subscriber
|
|
|
68 |
*/
|
|
|
69 |
public function removeSubscriber(EventSubscriberInterface $subscriber);
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Gets the listeners of a specific event or all listeners sorted by descending priority.
|
|
|
73 |
*
|
|
|
74 |
* @param string $eventName The name of the event
|
|
|
75 |
*
|
|
|
76 |
* @return array The event listeners for the specified event, or all event listeners by event name
|
|
|
77 |
*/
|
|
|
78 |
public function getListeners($eventName = null);
|
|
|
79 |
|
|
|
80 |
/**
|
|
|
81 |
* Gets the listener priority for a specific event.
|
|
|
82 |
*
|
|
|
83 |
* Returns null if the event or the listener does not exist.
|
|
|
84 |
*
|
|
|
85 |
* @param string $eventName The name of the event
|
|
|
86 |
* @param callable $listener The listener
|
|
|
87 |
*
|
|
|
88 |
* @return int|null The event listener priority
|
|
|
89 |
*/
|
|
|
90 |
public function getListenerPriority($eventName, $listener);
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* Checks whether an event has any registered listeners.
|
|
|
94 |
*
|
|
|
95 |
* @param string $eventName The name of the event
|
|
|
96 |
*
|
|
|
97 |
* @return bool true if the specified event has any listeners, false otherwise
|
|
|
98 |
*/
|
|
|
99 |
public function hasListeners($eventName = null);
|
|
|
100 |
}
|