]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
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 | * Event is the base class for classes containing event data. | |
16 | * | |
17 | * This class contains no event data. It is used by events that do not pass | |
18 | * state information to an event handler when an event is raised. | |
19 | * | |
20 | * You can call the method stopPropagation() to abort the execution of | |
21 | * further listeners in your event listener. | |
22 | * | |
23 | * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | |
24 | * @author Jonathan Wage <jonwage@gmail.com> | |
25 | * @author Roman Borschel <roman@code-factory.org> | |
26 | * @author Bernhard Schussek <bschussek@gmail.com> | |
27 | * | |
28 | * @api | |
29 | */ | |
30 | class Event | |
31 | { | |
32 | /** | |
33 | * @var Boolean Whether no further event listeners should be triggered | |
34 | */ | |
35 | private $propagationStopped = false; | |
36 | ||
37 | /** | |
38 | * @var EventDispatcher Dispatcher that dispatched this event | |
39 | */ | |
40 | private $dispatcher; | |
41 | ||
42 | /** | |
43 | * @var string This event's name | |
44 | */ | |
45 | private $name; | |
46 | ||
47 | /** | |
48 | * Returns whether further event listeners should be triggered. | |
49 | * | |
50 | * @see Event::stopPropagation | |
51 | * @return Boolean Whether propagation was already stopped for this event. | |
52 | * | |
53 | * @api | |
54 | */ | |
55 | public function isPropagationStopped() | |
56 | { | |
57 | return $this->propagationStopped; | |
58 | } | |
59 | ||
60 | /** | |
61 | * Stops the propagation of the event to further event listeners. | |
62 | * | |
63 | * If multiple event listeners are connected to the same event, no | |
64 | * further event listener will be triggered once any trigger calls | |
65 | * stopPropagation(). | |
66 | * | |
67 | * @api | |
68 | */ | |
69 | public function stopPropagation() | |
70 | { | |
71 | $this->propagationStopped = true; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Stores the EventDispatcher that dispatches this Event | |
76 | * | |
77 | * @param EventDispatcherInterface $dispatcher | |
78 | * | |
79 | * @api | |
80 | */ | |
81 | public function setDispatcher(EventDispatcherInterface $dispatcher) | |
82 | { | |
83 | $this->dispatcher = $dispatcher; | |
84 | } | |
85 | ||
86 | /** | |
87 | * Returns the EventDispatcher that dispatches this Event | |
88 | * | |
89 | * @return EventDispatcherInterface | |
90 | * | |
91 | * @api | |
92 | */ | |
93 | public function getDispatcher() | |
94 | { | |
95 | return $this->dispatcher; | |
96 | } | |
97 | ||
98 | /** | |
99 | * Gets the event's name. | |
100 | * | |
101 | * @return string | |
102 | * | |
103 | * @api | |
104 | */ | |
105 | public function getName() | |
106 | { | |
107 | return $this->name; | |
108 | } | |
109 | ||
110 | /** | |
111 | * Sets the event's name property. | |
112 | * | |
113 | * @param string $name The event name. | |
114 | * | |
115 | * @api | |
116 | */ | |
117 | public function setName($name) | |
118 | { | |
119 | $this->name = $name; | |
120 | } | |
121 | } |