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 bool 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: *
52: * @return bool Whether propagation was already stopped for this event.
53: *
54: * @api
55: */
56: public function isPropagationStopped()
57: {
58: return $this->propagationStopped;
59: }
60:
61: /**
62: * Stops the propagation of the event to further event listeners.
63: *
64: * If multiple event listeners are connected to the same event, no
65: * further event listener will be triggered once any trigger calls
66: * stopPropagation().
67: *
68: * @api
69: */
70: public function stopPropagation()
71: {
72: $this->propagationStopped = true;
73: }
74:
75: /**
76: * Stores the EventDispatcher that dispatches this Event.
77: *
78: * @param EventDispatcherInterface $dispatcher
79: *
80: * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
81: *
82: * @api
83: */
84: public function setDispatcher(EventDispatcherInterface $dispatcher)
85: {
86: $this->dispatcher = $dispatcher;
87: }
88:
89: /**
90: * Returns the EventDispatcher that dispatches this Event.
91: *
92: * @return EventDispatcherInterface
93: *
94: * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
95: *
96: * @api
97: */
98: public function getDispatcher()
99: {
100: return $this->dispatcher;
101: }
102:
103: /**
104: * Gets the event's name.
105: *
106: * @return string
107: *
108: * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call.
109: *
110: * @api
111: */
112: public function getName()
113: {
114: return $this->name;
115: }
116:
117: /**
118: * Sets the event's name property.
119: *
120: * @param string $name The event name.
121: *
122: * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call.
123: *
124: * @api
125: */
126: public function setName($name)
127: {
128: $this->name = $name;
129: }
130: }
131: