aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/event-dispatcher
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/event-dispatcher')
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore4
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md16
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php202
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php32
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php121
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php185
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php96
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php50
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php186
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php92
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE19
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md25
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php257
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php320
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php84
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php140
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php106
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json38
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist30
19 files changed, 0 insertions, 2003 deletions
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore
deleted file mode 100644
index 44de97a3..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
1vendor/
2composer.lock
3phpunit.xml
4
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md
deleted file mode 100644
index 536c5ac7..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md
+++ /dev/null
@@ -1,16 +0,0 @@
1CHANGELOG
2=========
3
42.1.0
5-----
6
7 * added TraceableEventDispatcherInterface
8 * added ContainerAwareEventDispatcher
9 * added a reference to the EventDispatcher on the Event
10 * added a reference to the Event name on the event
11 * added fluid interface to the dispatch() method which now returns the Event
12 object
13 * added GenericEvent event class
14 * added the possibility for subscribers to subscribe several times for the
15 same event
16 * added ImmutableEventDispatcher
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
deleted file mode 100644
index 9448ed43..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
+++ /dev/null
@@ -1,202 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher;
13
14use Symfony\Component\DependencyInjection\ContainerInterface;
15
16/**
17 * Lazily loads listeners and subscribers from the dependency injection
18 * container
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 * @author Bernhard Schussek <bschussek@gmail.com>
22 * @author Jordan Alliot <jordan.alliot@gmail.com>
23 */
24class ContainerAwareEventDispatcher extends EventDispatcher
25{
26 /**
27 * The container from where services are loaded
28 * @var ContainerInterface
29 */
30 private $container;
31
32 /**
33 * The service IDs of the event listeners and subscribers
34 * @var array
35 */
36 private $listenerIds = array();
37
38 /**
39 * The services registered as listeners
40 * @var array
41 */
42 private $listeners = array();
43
44 /**
45 * Constructor.
46 *
47 * @param ContainerInterface $container A ContainerInterface instance
48 */
49 public function __construct(ContainerInterface $container)
50 {
51 $this->container = $container;
52 }
53
54 /**
55 * Adds a service as event listener
56 *
57 * @param string $eventName Event for which the listener is added
58 * @param array $callback The service ID of the listener service & the method
59 * name that has to be called
60 * @param integer $priority The higher this value, the earlier an event listener
61 * will be triggered in the chain.
62 * Defaults to 0.
63 *
64 * @throws \InvalidArgumentException
65 */
66 public function addListenerService($eventName, $callback, $priority = 0)
67 {
68 if (!is_array($callback) || 2 !== count($callback)) {
69 throw new \InvalidArgumentException('Expected an array("service", "method") argument');
70 }
71
72 $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority);
73 }
74
75 public function removeListener($eventName, $listener)
76 {
77 $this->lazyLoad($eventName);
78
79 if (isset($this->listeners[$eventName])) {
80 foreach ($this->listeners[$eventName] as $key => $l) {
81 foreach ($this->listenerIds[$eventName] as $i => $args) {
82 list($serviceId, $method, $priority) = $args;
83 if ($key === $serviceId.'.'.$method) {
84 if ($listener === array($l, $method)) {
85 unset($this->listeners[$eventName][$key]);
86 if (empty($this->listeners[$eventName])) {
87 unset($this->listeners[$eventName]);
88 }
89 unset($this->listenerIds[$eventName][$i]);
90 if (empty($this->listenerIds[$eventName])) {
91 unset($this->listenerIds[$eventName]);
92 }
93 }
94 }
95 }
96 }
97 }
98
99 parent::removeListener($eventName, $listener);
100 }
101
102 /**
103 * @see EventDispatcherInterface::hasListeners
104 */
105 public function hasListeners($eventName = null)
106 {
107 if (null === $eventName) {
108 return (Boolean) count($this->listenerIds) || (Boolean) count($this->listeners);
109 }
110
111 if (isset($this->listenerIds[$eventName])) {
112 return true;
113 }
114
115 return parent::hasListeners($eventName);
116 }
117
118 /**
119 * @see EventDispatcherInterface::getListeners
120 */
121 public function getListeners($eventName = null)
122 {
123 if (null === $eventName) {
124 foreach (array_keys($this->listenerIds) as $serviceEventName) {
125 $this->lazyLoad($serviceEventName);
126 }
127 } else {
128 $this->lazyLoad($eventName);
129 }
130
131 return parent::getListeners($eventName);
132 }
133
134 /**
135 * Adds a service as event subscriber
136 *
137 * @param string $serviceId The service ID of the subscriber service
138 * @param string $class The service's class name (which must implement EventSubscriberInterface)
139 */
140 public function addSubscriberService($serviceId, $class)
141 {
142 foreach ($class::getSubscribedEvents() as $eventName => $params) {
143 if (is_string($params)) {
144 $this->listenerIds[$eventName][] = array($serviceId, $params, 0);
145 } elseif (is_string($params[0])) {
146 $this->listenerIds[$eventName][] = array($serviceId, $params[0], isset($params[1]) ? $params[1] : 0);
147 } else {
148 foreach ($params as $listener) {
149 $this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0);
150 }
151 }
152 }
153 }
154
155 /**
156 * {@inheritDoc}
157 *
158 * Lazily loads listeners for this event from the dependency injection
159 * container.
160 *
161 * @throws \InvalidArgumentException if the service is not defined
162 */
163 public function dispatch($eventName, Event $event = null)
164 {
165 $this->lazyLoad($eventName);
166
167 return parent::dispatch($eventName, $event);
168 }
169
170 public function getContainer()
171 {
172 return $this->container;
173 }
174
175 /**
176 * Lazily loads listeners for this event from the dependency injection
177 * container.
178 *
179 * @param string $eventName The name of the event to dispatch. The name of
180 * the event is the name of the method that is
181 * invoked on listeners.
182 */
183 protected function lazyLoad($eventName)
184 {
185 if (isset($this->listenerIds[$eventName])) {
186 foreach ($this->listenerIds[$eventName] as $args) {
187 list($serviceId, $method, $priority) = $args;
188 $listener = $this->container->get($serviceId);
189
190 $key = $serviceId.'.'.$method;
191 if (!isset($this->listeners[$eventName][$key])) {
192 $this->addListener($eventName, array($listener, $method), $priority);
193 } elseif ($listener !== $this->listeners[$eventName][$key]) {
194 parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
195 $this->addListener($eventName, array($listener, $method), $priority);
196 }
197
198 $this->listeners[$eventName][$key] = $listener;
199 }
200 }
201 }
202}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php
deleted file mode 100644
index a67a9790..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php
+++ /dev/null
@@ -1,32 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher\Debug;
13
14/**
15 * @author Fabien Potencier <fabien@symfony.com>
16 */
17interface TraceableEventDispatcherInterface
18{
19 /**
20 * Gets the called listeners.
21 *
22 * @return array An array of called listeners
23 */
24 public function getCalledListeners();
25
26 /**
27 * Gets the not called listeners.
28 *
29 * @return array An array of not called listeners
30 */
31 public function getNotCalledListeners();
32}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php
deleted file mode 100644
index 42f09eaa..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php
+++ /dev/null
@@ -1,121 +0,0 @@
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
12namespace 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 */
30class 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}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php
deleted file mode 100644
index eb1fb594..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php
+++ /dev/null
@@ -1,185 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher;
13
14/**
15 * The EventDispatcherInterface is the central point of Symfony's event listener system.
16 *
17 * Listeners are registered on the manager and events are dispatched through the
18 * manager.
19 *
20 * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
21 * @author Jonathan Wage <jonwage@gmail.com>
22 * @author Roman Borschel <roman@code-factory.org>
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 * @author Fabien Potencier <fabien@symfony.com>
25 * @author Jordi Boggiano <j.boggiano@seld.be>
26 * @author Jordan Alliot <jordan.alliot@gmail.com>
27 *
28 * @api
29 */
30class EventDispatcher implements EventDispatcherInterface
31{
32 private $listeners = array();
33 private $sorted = array();
34
35 /**
36 * @see EventDispatcherInterface::dispatch
37 *
38 * @api
39 */
40 public function dispatch($eventName, Event $event = null)
41 {
42 if (null === $event) {
43 $event = new Event();
44 }
45
46 $event->setDispatcher($this);
47 $event->setName($eventName);
48
49 if (!isset($this->listeners[$eventName])) {
50 return $event;
51 }
52
53 $this->doDispatch($this->getListeners($eventName), $eventName, $event);
54
55 return $event;
56 }
57
58 /**
59 * @see EventDispatcherInterface::getListeners
60 */
61 public function getListeners($eventName = null)
62 {
63 if (null !== $eventName) {
64 if (!isset($this->sorted[$eventName])) {
65 $this->sortListeners($eventName);
66 }
67
68 return $this->sorted[$eventName];
69 }
70
71 foreach (array_keys($this->listeners) as $eventName) {
72 if (!isset($this->sorted[$eventName])) {
73 $this->sortListeners($eventName);
74 }
75 }
76
77 return $this->sorted;
78 }
79
80 /**
81 * @see EventDispatcherInterface::hasListeners
82 */
83 public function hasListeners($eventName = null)
84 {
85 return (Boolean) count($this->getListeners($eventName));
86 }
87
88 /**
89 * @see EventDispatcherInterface::addListener
90 *
91 * @api
92 */
93 public function addListener($eventName, $listener, $priority = 0)
94 {
95 $this->listeners[$eventName][$priority][] = $listener;
96 unset($this->sorted[$eventName]);
97 }
98
99 /**
100 * @see EventDispatcherInterface::removeListener
101 */
102 public function removeListener($eventName, $listener)
103 {
104 if (!isset($this->listeners[$eventName])) {
105 return;
106 }
107
108 foreach ($this->listeners[$eventName] as $priority => $listeners) {
109 if (false !== ($key = array_search($listener, $listeners, true))) {
110 unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]);
111 }
112 }
113 }
114
115 /**
116 * @see EventDispatcherInterface::addSubscriber
117 *
118 * @api
119 */
120 public function addSubscriber(EventSubscriberInterface $subscriber)
121 {
122 foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
123 if (is_string($params)) {
124 $this->addListener($eventName, array($subscriber, $params));
125 } elseif (is_string($params[0])) {
126 $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
127 } else {
128 foreach ($params as $listener) {
129 $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
130 }
131 }
132 }
133 }
134
135 /**
136 * @see EventDispatcherInterface::removeSubscriber
137 */
138 public function removeSubscriber(EventSubscriberInterface $subscriber)
139 {
140 foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
141 if (is_array($params) && is_array($params[0])) {
142 foreach ($params as $listener) {
143 $this->removeListener($eventName, array($subscriber, $listener[0]));
144 }
145 } else {
146 $this->removeListener($eventName, array($subscriber, is_string($params) ? $params : $params[0]));
147 }
148 }
149 }
150
151 /**
152 * Triggers the listeners of an event.
153 *
154 * This method can be overridden to add functionality that is executed
155 * for each listener.
156 *
157 * @param array[callback] $listeners The event listeners.
158 * @param string $eventName The name of the event to dispatch.
159 * @param Event $event The event object to pass to the event handlers/listeners.
160 */
161 protected function doDispatch($listeners, $eventName, Event $event)
162 {
163 foreach ($listeners as $listener) {
164 call_user_func($listener, $event);
165 if ($event->isPropagationStopped()) {
166 break;
167 }
168 }
169 }
170
171 /**
172 * Sorts the internal list of listeners for the given event by priority.
173 *
174 * @param string $eventName The name of the event.
175 */
176 private function sortListeners($eventName)
177 {
178 $this->sorted[$eventName] = array();
179
180 if (isset($this->listeners[$eventName])) {
181 krsort($this->listeners[$eventName]);
182 $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
183 }
184 }
185}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
deleted file mode 100644
index 7aead23b..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
+++ /dev/null
@@ -1,96 +0,0 @@
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
12namespace 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 * @api
22 */
23interface EventDispatcherInterface
24{
25 /**
26 * Dispatches an event to all registered listeners.
27 *
28 * @param string $eventName The name of the event to dispatch. The name of
29 * the event is the name of the method that is
30 * invoked on listeners.
31 * @param Event $event The event to pass to the event handlers/listeners.
32 * If not supplied, an empty Event instance is created.
33 *
34 * @return Event
35 *
36 * @api
37 */
38 public function dispatch($eventName, Event $event = null);
39
40 /**
41 * Adds an event listener that listens on the specified events.
42 *
43 * @param string $eventName The event to listen on
44 * @param callable $listener The listener
45 * @param integer $priority The higher this value, the earlier an event
46 * listener will be triggered in the chain (defaults to 0)
47 *
48 * @api
49 */
50 public function addListener($eventName, $listener, $priority = 0);
51
52 /**
53 * Adds an event subscriber.
54 *
55 * The subscriber is asked for all the events he is
56 * interested in and added as a listener for these events.
57 *
58 * @param EventSubscriberInterface $subscriber The subscriber.
59 *
60 * @api
61 */
62 public function addSubscriber(EventSubscriberInterface $subscriber);
63
64 /**
65 * Removes an event listener from the specified events.
66 *
67 * @param string|array $eventName The event(s) to remove a listener from
68 * @param callable $listener The listener to remove
69 */
70 public function removeListener($eventName, $listener);
71
72 /**
73 * Removes an event subscriber.
74 *
75 * @param EventSubscriberInterface $subscriber The subscriber
76 */
77 public function removeSubscriber(EventSubscriberInterface $subscriber);
78
79 /**
80 * Gets the listeners of a specific event or all listeners.
81 *
82 * @param string $eventName The name of the event
83 *
84 * @return array The event listeners for the specified event, or all event listeners by event name
85 */
86 public function getListeners($eventName = null);
87
88 /**
89 * Checks whether an event has any registered listeners.
90 *
91 * @param string $eventName The name of the event
92 *
93 * @return Boolean true if the specified event has any listeners, false otherwise
94 */
95 public function hasListeners($eventName = null);
96}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
deleted file mode 100644
index 080f892f..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
+++ /dev/null
@@ -1,50 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher;
13
14/**
15 * An EventSubscriber knows himself what events he is interested in.
16 * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
17 * {@link getSubscribedEvents} and registers the subscriber as a listener for all
18 * returned events.
19 *
20 * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
21 * @author Jonathan Wage <jonwage@gmail.com>
22 * @author Roman Borschel <roman@code-factory.org>
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 *
25 * @api
26 */
27interface EventSubscriberInterface
28{
29 /**
30 * Returns an array of event names this subscriber wants to listen to.
31 *
32 * The array keys are event names and the value can be:
33 *
34 * * The method name to call (priority defaults to 0)
35 * * An array composed of the method name to call and the priority
36 * * An array of arrays composed of the method names to call and respective
37 * priorities, or 0 if unset
38 *
39 * For instance:
40 *
41 * * array('eventName' => 'methodName')
42 * * array('eventName' => array('methodName', $priority))
43 * * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
44 *
45 * @return array The event names to listen to
46 *
47 * @api
48 */
49 public static function getSubscribedEvents();
50}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php
deleted file mode 100644
index 3a5efcfe..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php
+++ /dev/null
@@ -1,186 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher;
13
14/**
15 * Event encapsulation class.
16 *
17 * Encapsulates events thus decoupling the observer from the subject they encapsulate.
18 *
19 * @author Drak <drak@zikula.org>
20 */
21class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
22{
23 /**
24 * Observer pattern subject.
25 *
26 * @var mixed usually object or callable
27 */
28 protected $subject;
29
30 /**
31 * Array of arguments.
32 *
33 * @var array
34 */
35 protected $arguments;
36
37 /**
38 * Encapsulate an event with $subject and $args.
39 *
40 * @param mixed $subject The subject of the event, usually an object.
41 * @param array $arguments Arguments to store in the event.
42 */
43 public function __construct($subject = null, array $arguments = array())
44 {
45 $this->subject = $subject;
46 $this->arguments = $arguments;
47 }
48
49 /**
50 * Getter for subject property.
51 *
52 * @return mixed $subject The observer subject.
53 */
54 public function getSubject()
55 {
56 return $this->subject;
57 }
58
59 /**
60 * Get argument by key.
61 *
62 * @param string $key Key.
63 *
64 * @throws \InvalidArgumentException If key is not found.
65 *
66 * @return mixed Contents of array key.
67 */
68 public function getArgument($key)
69 {
70 if ($this->hasArgument($key)) {
71 return $this->arguments[$key];
72 }
73
74 throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
75 }
76
77 /**
78 * Add argument to event.
79 *
80 * @param string $key Argument name.
81 * @param mixed $value Value.
82 *
83 * @return GenericEvent
84 */
85 public function setArgument($key, $value)
86 {
87 $this->arguments[$key] = $value;
88
89 return $this;
90 }
91
92 /**
93 * Getter for all arguments.
94 *
95 * @return array
96 */
97 public function getArguments()
98 {
99 return $this->arguments;
100 }
101
102 /**
103 * Set args property.
104 *
105 * @param array $args Arguments.
106 *
107 * @return GenericEvent
108 */
109 public function setArguments(array $args = array())
110 {
111 $this->arguments = $args;
112
113 return $this;
114 }
115
116 /**
117 * Has argument.
118 *
119 * @param string $key Key of arguments array.
120 *
121 * @return boolean
122 */
123 public function hasArgument($key)
124 {
125 return array_key_exists($key, $this->arguments);
126 }
127
128 /**
129 * ArrayAccess for argument getter.
130 *
131 * @param string $key Array key.
132 *
133 * @throws \InvalidArgumentException If key does not exist in $this->args.
134 *
135 * @return mixed
136 */
137 public function offsetGet($key)
138 {
139 return $this->getArgument($key);
140 }
141
142 /**
143 * ArrayAccess for argument setter.
144 *
145 * @param string $key Array key to set.
146 * @param mixed $value Value.
147 */
148 public function offsetSet($key, $value)
149 {
150 $this->setArgument($key, $value);
151 }
152
153 /**
154 * ArrayAccess for unset argument.
155 *
156 * @param string $key Array key.
157 */
158 public function offsetUnset($key)
159 {
160 if ($this->hasArgument($key)) {
161 unset($this->arguments[$key]);
162 }
163 }
164
165 /**
166 * ArrayAccess has argument.
167 *
168 * @param string $key Array key.
169 *
170 * @return boolean
171 */
172 public function offsetExists($key)
173 {
174 return $this->hasArgument($key);
175 }
176
177 /**
178 * IteratorAggregate for iterating over the object like an array
179 *
180 * @return \ArrayIterator
181 */
182 public function getIterator()
183 {
184 return new \ArrayIterator($this->arguments);
185 }
186}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
deleted file mode 100644
index b70b81a8..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
+++ /dev/null
@@ -1,92 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher;
13
14/**
15 * A read-only proxy for an event dispatcher.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class ImmutableEventDispatcher implements EventDispatcherInterface
20{
21 /**
22 * The proxied dispatcher.
23 * @var EventDispatcherInterface
24 */
25 private $dispatcher;
26
27 /**
28 * Creates an unmodifiable proxy for an event dispatcher.
29 *
30 * @param EventDispatcherInterface $dispatcher The proxied event dispatcher.
31 */
32 public function __construct(EventDispatcherInterface $dispatcher)
33 {
34 $this->dispatcher = $dispatcher;
35 }
36
37 /**
38 * {@inheritdoc}
39 */
40 public function dispatch($eventName, Event $event = null)
41 {
42 return $this->dispatcher->dispatch($eventName, $event);
43 }
44
45 /**
46 * {@inheritdoc}
47 */
48 public function addListener($eventName, $listener, $priority = 0)
49 {
50 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function addSubscriber(EventSubscriberInterface $subscriber)
57 {
58 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public function removeListener($eventName, $listener)
65 {
66 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
67 }
68
69 /**
70 * {@inheritdoc}
71 */
72 public function removeSubscriber(EventSubscriberInterface $subscriber)
73 {
74 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function getListeners($eventName = null)
81 {
82 return $this->dispatcher->getListeners($eventName);
83 }
84
85 /**
86 * {@inheritdoc}
87 */
88 public function hasListeners($eventName = null)
89 {
90 return $this->dispatcher->hasListeners($eventName);
91 }
92}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE
deleted file mode 100644
index 88a57f8d..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
1Copyright (c) 2004-2013 Fabien Potencier
2
3Permission is hereby granted, free of charge, to any person obtaining a copy
4of this software and associated documentation files (the "Software"), to deal
5in the Software without restriction, including without limitation the rights
6to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7copies of the Software, and to permit persons to whom the Software is furnished
8to do so, subject to the following conditions:
9
10The above copyright notice and this permission notice shall be included in all
11copies or substantial portions of the Software.
12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19THE SOFTWARE.
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md
deleted file mode 100644
index 11f6b188..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
1EventDispatcher Component
2=========================
3
4EventDispatcher implements a lightweight version of the Observer design
5pattern.
6
7 use Symfony\Component\EventDispatcher\EventDispatcher;
8 use Symfony\Component\EventDispatcher\Event;
9
10 $dispatcher = new EventDispatcher();
11
12 $dispatcher->addListener('event_name', function (Event $event) {
13 // ...
14 });
15
16 $dispatcher->dispatch('event_name');
17
18Resources
19---------
20
21You can run the unit tests with the following command:
22
23 $ cd path/to/Symfony/Component/EventDispatcher/
24 $ composer.phar install --dev
25 $ phpunit
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
deleted file mode 100644
index 71f3ad05..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
+++ /dev/null
@@ -1,257 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\DependencyInjection\Container;
15use Symfony\Component\DependencyInjection\Scope;
16use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
17use Symfony\Component\EventDispatcher\Event;
18use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19
20class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
21{
22 protected function setUp()
23 {
24 if (!class_exists('Symfony\Component\DependencyInjection\Container')) {
25 $this->markTestSkipped('The "DependencyInjection" component is not available');
26 }
27 }
28
29 public function testAddAListenerService()
30 {
31 $event = new Event();
32
33 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
34
35 $service
36 ->expects($this->once())
37 ->method('onEvent')
38 ->with($event)
39 ;
40
41 $container = new Container();
42 $container->set('service.listener', $service);
43
44 $dispatcher = new ContainerAwareEventDispatcher($container);
45 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
46
47 $dispatcher->dispatch('onEvent', $event);
48 }
49
50 public function testAddASubscriberService()
51 {
52 $event = new Event();
53
54 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');
55
56 $service
57 ->expects($this->once())
58 ->method('onEvent')
59 ->with($event)
60 ;
61
62 $container = new Container();
63 $container->set('service.subscriber', $service);
64
65 $dispatcher = new ContainerAwareEventDispatcher($container);
66 $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService');
67
68 $dispatcher->dispatch('onEvent', $event);
69 }
70
71 public function testPreventDuplicateListenerService()
72 {
73 $event = new Event();
74
75 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
76
77 $service
78 ->expects($this->once())
79 ->method('onEvent')
80 ->with($event)
81 ;
82
83 $container = new Container();
84 $container->set('service.listener', $service);
85
86 $dispatcher = new ContainerAwareEventDispatcher($container);
87 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5);
88 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10);
89
90 $dispatcher->dispatch('onEvent', $event);
91 }
92
93 /**
94 * @expectedException \InvalidArgumentException
95 */
96 public function testTriggerAListenerServiceOutOfScope()
97 {
98 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
99
100 $scope = new Scope('scope');
101 $container = new Container();
102 $container->addScope($scope);
103 $container->enterScope('scope');
104
105 $container->set('service.listener', $service, 'scope');
106
107 $dispatcher = new ContainerAwareEventDispatcher($container);
108 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
109
110 $container->leaveScope('scope');
111 $dispatcher->dispatch('onEvent');
112 }
113
114 public function testReEnteringAScope()
115 {
116 $event = new Event();
117
118 $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
119
120 $service1
121 ->expects($this->exactly(2))
122 ->method('onEvent')
123 ->with($event)
124 ;
125
126 $scope = new Scope('scope');
127 $container = new Container();
128 $container->addScope($scope);
129 $container->enterScope('scope');
130
131 $container->set('service.listener', $service1, 'scope');
132
133 $dispatcher = new ContainerAwareEventDispatcher($container);
134 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
135 $dispatcher->dispatch('onEvent', $event);
136
137 $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
138
139 $service2
140 ->expects($this->once())
141 ->method('onEvent')
142 ->with($event)
143 ;
144
145 $container->enterScope('scope');
146 $container->set('service.listener', $service2, 'scope');
147
148 $dispatcher->dispatch('onEvent', $event);
149
150 $container->leaveScope('scope');
151
152 $dispatcher->dispatch('onEvent');
153 }
154
155 public function testHasListenersOnLazyLoad()
156 {
157 $event = new Event();
158
159 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
160
161 $container = new Container();
162 $container->set('service.listener', $service);
163
164 $dispatcher = new ContainerAwareEventDispatcher($container);
165 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
166
167 $event->setDispatcher($dispatcher);
168 $event->setName('onEvent');
169
170 $service
171 ->expects($this->once())
172 ->method('onEvent')
173 ->with($event)
174 ;
175
176 $this->assertTrue($dispatcher->hasListeners());
177
178 if ($dispatcher->hasListeners('onEvent')) {
179 $dispatcher->dispatch('onEvent');
180 }
181 }
182
183 public function testGetListenersOnLazyLoad()
184 {
185 $event = new Event();
186
187 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
188
189 $container = new Container();
190 $container->set('service.listener', $service);
191
192 $dispatcher = new ContainerAwareEventDispatcher($container);
193 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
194
195 $listeners = $dispatcher->getListeners();
196
197 $this->assertTrue(isset($listeners['onEvent']));
198
199 $this->assertCount(1, $dispatcher->getListeners('onEvent'));
200 }
201
202 public function testRemoveAfterDispatch()
203 {
204 $event = new Event();
205
206 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
207
208 $container = new Container();
209 $container->set('service.listener', $service);
210
211 $dispatcher = new ContainerAwareEventDispatcher($container);
212 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
213
214 $dispatcher->dispatch('onEvent', new Event());
215 $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
216 $this->assertFalse($dispatcher->hasListeners('onEvent'));
217 }
218
219 public function testRemoveBeforeDispatch()
220 {
221 $event = new Event();
222
223 $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
224
225 $container = new Container();
226 $container->set('service.listener', $service);
227
228 $dispatcher = new ContainerAwareEventDispatcher($container);
229 $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
230
231 $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
232 $this->assertFalse($dispatcher->hasListeners('onEvent'));
233 }
234}
235
236class Service
237{
238 public function onEvent(Event $e)
239 {
240 }
241}
242
243class SubscriberService implements EventSubscriberInterface
244{
245 public static function getSubscribedEvents()
246 {
247 return array(
248 'onEvent' => 'onEvent',
249 'onEvent' => array('onEvent', 10),
250 'onEvent' => array('onEvent'),
251 );
252 }
253
254 public function onEvent(Event $e)
255 {
256 }
257}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
deleted file mode 100644
index ad7e4484..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
+++ /dev/null
@@ -1,320 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\EventDispatcher\EventDispatcher;
16use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18class EventDispatcherTest extends \PHPUnit_Framework_TestCase
19{
20 /* Some pseudo events */
21 const preFoo = 'pre.foo';
22 const postFoo = 'post.foo';
23 const preBar = 'pre.bar';
24 const postBar = 'post.bar';
25
26 private $dispatcher;
27
28 private $listener;
29
30 protected function setUp()
31 {
32 $this->dispatcher = new EventDispatcher();
33 $this->listener = new TestEventListener();
34 }
35
36 protected function tearDown()
37 {
38 $this->dispatcher = null;
39 $this->listener = null;
40 }
41
42 public function testInitialState()
43 {
44 $this->assertEquals(array(), $this->dispatcher->getListeners());
45 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
46 $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
47 }
48
49 public function testAddListener()
50 {
51 $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
52 $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
53 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
54 $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
55 $this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
56 $this->assertCount(1, $this->dispatcher->getListeners(self::postFoo));
57 $this->assertCount(2, $this->dispatcher->getListeners());
58 }
59
60 public function testGetListenersSortsByPriority()
61 {
62 $listener1 = new TestEventListener();
63 $listener2 = new TestEventListener();
64 $listener3 = new TestEventListener();
65 $listener1->name = '1';
66 $listener2->name = '2';
67 $listener3->name = '3';
68
69 $this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10);
70 $this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10);
71 $this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo'));
72
73 $expected = array(
74 array($listener2, 'preFoo'),
75 array($listener3, 'preFoo'),
76 array($listener1, 'preFoo'),
77 );
78
79 $this->assertSame($expected, $this->dispatcher->getListeners('pre.foo'));
80 }
81
82 public function testGetAllListenersSortsByPriority()
83 {
84 $listener1 = new TestEventListener();
85 $listener2 = new TestEventListener();
86 $listener3 = new TestEventListener();
87 $listener4 = new TestEventListener();
88 $listener5 = new TestEventListener();
89 $listener6 = new TestEventListener();
90
91 $this->dispatcher->addListener('pre.foo', $listener1, -10);
92 $this->dispatcher->addListener('pre.foo', $listener2);
93 $this->dispatcher->addListener('pre.foo', $listener3, 10);
94 $this->dispatcher->addListener('post.foo', $listener4, -10);
95 $this->dispatcher->addListener('post.foo', $listener5);
96 $this->dispatcher->addListener('post.foo', $listener6, 10);
97
98 $expected = array(
99 'pre.foo' => array($listener3, $listener2, $listener1),
100 'post.foo' => array($listener6, $listener5, $listener4),
101 );
102
103 $this->assertSame($expected, $this->dispatcher->getListeners());
104 }
105
106 public function testDispatch()
107 {
108 $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
109 $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
110 $this->dispatcher->dispatch(self::preFoo);
111 $this->assertTrue($this->listener->preFooInvoked);
112 $this->assertFalse($this->listener->postFooInvoked);
113 $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent'));
114 $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
115 $event = new Event();
116 $return = $this->dispatcher->dispatch(self::preFoo, $event);
117 $this->assertEquals('pre.foo', $event->getName());
118 $this->assertSame($event, $return);
119 }
120
121 public function testDispatchForClosure()
122 {
123 $invoked = 0;
124 $listener = function () use (&$invoked) {
125 $invoked++;
126 };
127 $this->dispatcher->addListener('pre.foo', $listener);
128 $this->dispatcher->addListener('post.foo', $listener);
129 $this->dispatcher->dispatch(self::preFoo);
130 $this->assertEquals(1, $invoked);
131 }
132
133 public function testStopEventPropagation()
134 {
135 $otherListener = new TestEventListener();
136
137 // postFoo() stops the propagation, so only one listener should
138 // be executed
139 // Manually set priority to enforce $this->listener to be called first
140 $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10);
141 $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo'));
142 $this->dispatcher->dispatch(self::postFoo);
143 $this->assertTrue($this->listener->postFooInvoked);
144 $this->assertFalse($otherListener->postFooInvoked);
145 }
146
147 public function testDispatchByPriority()
148 {
149 $invoked = array();
150 $listener1 = function () use (&$invoked) {
151 $invoked[] = '1';
152 };
153 $listener2 = function () use (&$invoked) {
154 $invoked[] = '2';
155 };
156 $listener3 = function () use (&$invoked) {
157 $invoked[] = '3';
158 };
159 $this->dispatcher->addListener('pre.foo', $listener1, -10);
160 $this->dispatcher->addListener('pre.foo', $listener2);
161 $this->dispatcher->addListener('pre.foo', $listener3, 10);
162 $this->dispatcher->dispatch(self::preFoo);
163 $this->assertEquals(array('3', '2', '1'), $invoked);
164 }
165
166 public function testRemoveListener()
167 {
168 $this->dispatcher->addListener('pre.bar', $this->listener);
169 $this->assertTrue($this->dispatcher->hasListeners(self::preBar));
170 $this->dispatcher->removeListener('pre.bar', $this->listener);
171 $this->assertFalse($this->dispatcher->hasListeners(self::preBar));
172 $this->dispatcher->removeListener('notExists', $this->listener);
173 }
174
175 public function testAddSubscriber()
176 {
177 $eventSubscriber = new TestEventSubscriber();
178 $this->dispatcher->addSubscriber($eventSubscriber);
179 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
180 $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
181 }
182
183 public function testAddSubscriberWithPriorities()
184 {
185 $eventSubscriber = new TestEventSubscriber();
186 $this->dispatcher->addSubscriber($eventSubscriber);
187
188 $eventSubscriber = new TestEventSubscriberWithPriorities();
189 $this->dispatcher->addSubscriber($eventSubscriber);
190
191 $listeners = $this->dispatcher->getListeners('pre.foo');
192 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
193 $this->assertCount(2, $listeners);
194 $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]);
195 }
196
197 public function testAddSubscriberWithMultipleListeners()
198 {
199 $eventSubscriber = new TestEventSubscriberWithMultipleListeners();
200 $this->dispatcher->addSubscriber($eventSubscriber);
201
202 $listeners = $this->dispatcher->getListeners('pre.foo');
203 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
204 $this->assertCount(2, $listeners);
205 $this->assertEquals('preFoo2', $listeners[0][1]);
206 }
207
208 public function testRemoveSubscriber()
209 {
210 $eventSubscriber = new TestEventSubscriber();
211 $this->dispatcher->addSubscriber($eventSubscriber);
212 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
213 $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
214 $this->dispatcher->removeSubscriber($eventSubscriber);
215 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
216 $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
217 }
218
219 public function testRemoveSubscriberWithPriorities()
220 {
221 $eventSubscriber = new TestEventSubscriberWithPriorities();
222 $this->dispatcher->addSubscriber($eventSubscriber);
223 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
224 $this->dispatcher->removeSubscriber($eventSubscriber);
225 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
226 }
227
228 public function testRemoveSubscriberWithMultipleListeners()
229 {
230 $eventSubscriber = new TestEventSubscriberWithMultipleListeners();
231 $this->dispatcher->addSubscriber($eventSubscriber);
232 $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
233 $this->assertCount(2, $this->dispatcher->getListeners(self::preFoo));
234 $this->dispatcher->removeSubscriber($eventSubscriber);
235 $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
236 }
237
238 public function testEventReceivesTheDispatcherInstance()
239 {
240 $test = $this;
241 $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
242 $dispatcher = $event->getDispatcher();
243 });
244 $this->dispatcher->dispatch('test');
245 $this->assertSame($this->dispatcher, $dispatcher);
246 }
247
248 /**
249 * @see https://bugs.php.net/bug.php?id=62976
250 *
251 * This bug affects:
252 * - The PHP 5.3 branch for versions < 5.3.18
253 * - The PHP 5.4 branch for versions < 5.4.8
254 * - The PHP 5.5 branch is not affected
255 */
256 public function testWorkaroundForPhpBug62976()
257 {
258 $dispatcher = new EventDispatcher();
259 $dispatcher->addListener('bug.62976', new CallableClass());
260 $dispatcher->removeListener('bug.62976', function() {});
261 $this->assertTrue($dispatcher->hasListeners('bug.62976'));
262 }
263}
264
265class CallableClass
266{
267 public function __invoke()
268 {
269 }
270}
271
272class TestEventListener
273{
274 public $preFooInvoked = false;
275 public $postFooInvoked = false;
276
277 /* Listener methods */
278
279 public function preFoo(Event $e)
280 {
281 $this->preFooInvoked = true;
282 }
283
284 public function postFoo(Event $e)
285 {
286 $this->postFooInvoked = true;
287
288 $e->stopPropagation();
289 }
290}
291
292class TestEventSubscriber implements EventSubscriberInterface
293{
294 public static function getSubscribedEvents()
295 {
296 return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo');
297 }
298}
299
300class TestEventSubscriberWithPriorities implements EventSubscriberInterface
301{
302 public static function getSubscribedEvents()
303 {
304 return array(
305 'pre.foo' => array('preFoo', 10),
306 'post.foo' => array('postFoo'),
307 );
308 }
309}
310
311class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface
312{
313 public static function getSubscribedEvents()
314 {
315 return array('pre.foo' => array(
316 array('preFoo1'),
317 array('preFoo2', 10)
318 ));
319 }
320}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php
deleted file mode 100644
index 52aa9ad6..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php
+++ /dev/null
@@ -1,84 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\EventDispatcher\EventDispatcher;
16
17/**
18 * Test class for Event.
19 */
20class EventTest extends \PHPUnit_Framework_TestCase
21{
22 /**
23 * @var \Symfony\Component\EventDispatcher\Event
24 */
25 protected $event;
26
27 /**
28 * @var \Symfony\Component\EventDispatcher\EventDispatcher
29 */
30 protected $dispatcher;
31
32 /**
33 * Sets up the fixture, for example, opens a network connection.
34 * This method is called before a test is executed.
35 */
36 protected function setUp()
37 {
38 $this->event = new Event;
39 $this->dispatcher = new EventDispatcher();
40 }
41
42 /**
43 * Tears down the fixture, for example, closes a network connection.
44 * This method is called after a test is executed.
45 */
46 protected function tearDown()
47 {
48 $this->event = null;
49 $this->eventDispatcher = null;
50 }
51
52 public function testIsPropagationStopped()
53 {
54 $this->assertFalse($this->event->isPropagationStopped());
55 }
56
57 public function testStopPropagationAndIsPropagationStopped()
58 {
59 $this->event->stopPropagation();
60 $this->assertTrue($this->event->isPropagationStopped());
61 }
62
63 public function testSetDispatcher()
64 {
65 $this->event->setDispatcher($this->dispatcher);
66 $this->assertSame($this->dispatcher, $this->event->getDispatcher());
67 }
68
69 public function testGetDispatcher()
70 {
71 $this->assertNull($this->event->getDispatcher());
72 }
73
74 public function testGetName()
75 {
76 $this->assertNull($this->event->getName());
77 }
78
79 public function testSetName()
80 {
81 $this->event->setName('foo');
82 $this->assertEquals('foo', $this->event->getName());
83 }
84}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
deleted file mode 100644
index 8dd6f5b4..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
+++ /dev/null
@@ -1,140 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\GenericEvent;
15
16/**
17 * Test class for Event.
18 */
19class GenericEventTest extends \PHPUnit_Framework_TestCase
20{
21
22 /**
23 * @var GenericEvent
24 */
25 private $event;
26
27 private $subject;
28
29 /**
30 * Prepares the environment before running a test.
31 */
32 protected function setUp()
33 {
34 parent::setUp();
35
36 $this->subject = new \StdClass();
37 $this->event = new GenericEvent($this->subject, array('name' => 'Event'), 'foo');
38 }
39
40 /**
41 * Cleans up the environment after running a test.
42 */
43 protected function tearDown()
44 {
45 $this->subject = null;
46 $this->event = null;
47
48 parent::tearDown();
49 }
50
51 public function testConstruct()
52 {
53 $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event')));
54 }
55
56 /**
57 * Tests Event->getArgs()
58 */
59 public function testGetArguments()
60 {
61 // test getting all
62 $this->assertSame(array('name' => 'Event'), $this->event->getArguments());
63 }
64
65 public function testSetArguments()
66 {
67 $result = $this->event->setArguments(array('foo' => 'bar'));
68 $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event);
69 $this->assertSame($this->event, $result);
70 }
71
72 public function testSetArgument()
73 {
74 $result = $this->event->setArgument('foo2', 'bar2');
75 $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
76 $this->assertEquals($this->event, $result);
77 }
78
79 public function testGetArgument()
80 {
81 // test getting key
82 $this->assertEquals('Event', $this->event->getArgument('name'));
83 }
84
85 /**
86 * @expectedException \InvalidArgumentException
87 */
88 public function testGetArgException()
89 {
90 $this->event->getArgument('nameNotExist');
91 }
92
93 public function testOffsetGet()
94 {
95 // test getting key
96 $this->assertEquals('Event', $this->event['name']);
97
98 // test getting invalid arg
99 $this->setExpectedException('InvalidArgumentException');
100 $this->assertFalse($this->event['nameNotExist']);
101 }
102
103 public function testOffsetSet()
104 {
105 $this->event['foo2'] = 'bar2';
106 $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
107 }
108
109 public function testOffsetUnset()
110 {
111 unset($this->event['name']);
112 $this->assertAttributeSame(array(), 'arguments', $this->event);
113 }
114
115 public function testOffsetIsset()
116 {
117 $this->assertTrue(isset($this->event['name']));
118 $this->assertFalse(isset($this->event['nameNotExist']));
119 }
120
121 public function testHasArgument()
122 {
123 $this->assertTrue($this->event->hasArgument('name'));
124 $this->assertFalse($this->event->hasArgument('nameNotExist'));
125 }
126
127 public function testGetSubject()
128 {
129 $this->assertSame($this->subject, $this->event->getSubject());
130 }
131
132 public function testHasIterator()
133 {
134 $data = array();
135 foreach ($this->event as $key => $value) {
136 $data[$key] = $value;
137 }
138 $this->assertEquals(array('name' => 'Event'), $data);
139 }
140}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
deleted file mode 100644
index 6402f89f..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
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
12namespace Symfony\Component\EventDispatcher\Tests;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
16use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18/**
19 * @author Bernhard Schussek <bschussek@gmail.com>
20 */
21class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
22{
23 /**
24 * @var \PHPUnit_Framework_MockObject_MockObject
25 */
26 private $innerDispatcher;
27
28 /**
29 * @var ImmutableEventDispatcher
30 */
31 private $dispatcher;
32
33 protected function setUp()
34 {
35 $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
36 $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
37 }
38
39 public function testDispatchDelegates()
40 {
41 $event = new Event();
42
43 $this->innerDispatcher->expects($this->once())
44 ->method('dispatch')
45 ->with('event', $event)
46 ->will($this->returnValue('result'));
47
48 $this->assertSame('result', $this->dispatcher->dispatch('event', $event));
49 }
50
51 public function testGetListenersDelegates()
52 {
53 $this->innerDispatcher->expects($this->once())
54 ->method('getListeners')
55 ->with('event')
56 ->will($this->returnValue('result'));
57
58 $this->assertSame('result', $this->dispatcher->getListeners('event'));
59 }
60
61 public function testHasListenersDelegates()
62 {
63 $this->innerDispatcher->expects($this->once())
64 ->method('hasListeners')
65 ->with('event')
66 ->will($this->returnValue('result'));
67
68 $this->assertSame('result', $this->dispatcher->hasListeners('event'));
69 }
70
71 /**
72 * @expectedException \BadMethodCallException
73 */
74 public function testAddListenerDisallowed()
75 {
76 $this->dispatcher->addListener('event', function () { return 'foo'; });
77 }
78
79 /**
80 * @expectedException \BadMethodCallException
81 */
82 public function testAddSubscriberDisallowed()
83 {
84 $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
85
86 $this->dispatcher->addSubscriber($subscriber);
87 }
88
89 /**
90 * @expectedException \BadMethodCallException
91 */
92 public function testRemoveListenerDisallowed()
93 {
94 $this->dispatcher->removeListener('event', function () { return 'foo'; });
95 }
96
97 /**
98 * @expectedException \BadMethodCallException
99 */
100 public function testRemoveSubscriberDisallowed()
101 {
102 $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
103
104 $this->dispatcher->removeSubscriber($subscriber);
105 }
106}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json
deleted file mode 100644
index 1db2ecfd..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json
+++ /dev/null
@@ -1,38 +0,0 @@
1{
2 "name": "symfony/event-dispatcher",
3 "type": "library",
4 "description": "Symfony EventDispatcher Component",
5 "keywords": [],
6 "homepage": "http://symfony.com",
7 "license": "MIT",
8 "authors": [
9 {
10 "name": "Fabien Potencier",
11 "email": "fabien@symfony.com"
12 },
13 {
14 "name": "Symfony Community",
15 "homepage": "http://symfony.com/contributors"
16 }
17 ],
18 "require": {
19 "php": ">=5.3.3"
20 },
21 "require-dev": {
22 "symfony/dependency-injection": "~2.0"
23 },
24 "suggest": {
25 "symfony/dependency-injection": "",
26 "symfony/http-kernel": ""
27 },
28 "autoload": {
29 "psr-0": { "Symfony\\Component\\EventDispatcher\\": "" }
30 },
31 "target-dir": "Symfony/Component/EventDispatcher",
32 "minimum-stability": "dev",
33 "extra": {
34 "branch-alias": {
35 "dev-master": "2.3-dev"
36 }
37 }
38}
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist
deleted file mode 100644
index 0c3de4f7..00000000
--- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist
+++ /dev/null
@@ -1,30 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2
3<phpunit backupGlobals="false"
4 backupStaticAttributes="false"
5 colors="true"
6 convertErrorsToExceptions="true"
7 convertNoticesToExceptions="true"
8 convertWarningsToExceptions="true"
9 processIsolation="false"
10 stopOnFailure="false"
11 syntaxCheck="false"
12 bootstrap="vendor/autoload.php"
13>
14 <testsuites>
15 <testsuite name="Symfony EventDispatcher Component Test Suite">
16 <directory>./Tests/</directory>
17 </testsuite>
18 </testsuites>
19
20 <filter>
21 <whitelist>
22 <directory>./</directory>
23 <exclude>
24 <directory>./Resources</directory>
25 <directory>./Tests</directory>
26 <directory>./vendor</directory>
27 </exclude>
28 </whitelist>
29 </filter>
30</phpunit>