Yaffs site version 1.1
[yaffs-website] / vendor / symfony / event-dispatcher / Event.php
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 class Event
29 {
30     /**
31      * @var bool Whether no further event listeners should be triggered
32      */
33     private $propagationStopped = false;
34
35     /**
36      * @var EventDispatcherInterface Dispatcher that dispatched this event
37      */
38     private $dispatcher;
39
40     /**
41      * @var string This event's name
42      */
43     private $name;
44
45     /**
46      * Returns whether further event listeners should be triggered.
47      *
48      * @see Event::stopPropagation()
49      *
50      * @return bool Whether propagation was already stopped for this event
51      */
52     public function isPropagationStopped()
53     {
54         return $this->propagationStopped;
55     }
56
57     /**
58      * Stops the propagation of the event to further event listeners.
59      *
60      * If multiple event listeners are connected to the same event, no
61      * further event listener will be triggered once any trigger calls
62      * stopPropagation().
63      */
64     public function stopPropagation()
65     {
66         $this->propagationStopped = true;
67     }
68
69     /**
70      * Stores the EventDispatcher that dispatches this Event.
71      *
72      * @param EventDispatcherInterface $dispatcher
73      *
74      * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
75      */
76     public function setDispatcher(EventDispatcherInterface $dispatcher)
77     {
78         $this->dispatcher = $dispatcher;
79     }
80
81     /**
82      * Returns the EventDispatcher that dispatches this Event.
83      *
84      * @return EventDispatcherInterface
85      *
86      * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
87      */
88     public function getDispatcher()
89     {
90         @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED);
91
92         return $this->dispatcher;
93     }
94
95     /**
96      * Gets the event's name.
97      *
98      * @return string
99      *
100      * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
101      */
102     public function getName()
103     {
104         @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED);
105
106         return $this->name;
107     }
108
109     /**
110      * Sets the event's name property.
111      *
112      * @param string $name The event name
113      *
114      * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
115      */
116     public function setName($name)
117     {
118         $this->name = $name;
119     }
120 }