8000 Backported new behaviour from PR #2148 and removed check for interfac… · symfony/symfony@21cf0ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 21cf0ac

Browse files
committed
Backported new behaviour from PR #2148 and removed check for interface at run-time
1 parent 8b240d4 commit 21cf0ac

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,20 @@ public function getListeners($eventName = null)
107107
/**
108108
* Adds a service as event subscriber
109109
*
110-
* If this service is created by a factory, its class value must be correctly filled.
111-
* The service's class must implement Symfony\Component\EventDispatcher\EventSubscriberInterface.
112-
*
113110
* @param string $serviceId The service ID of the subscriber service
114-
* @param string $class The service's class name
111+
* @param string $class The service's class name (which must implement EventSubscriberInterface)
115112
*/
116113
public function addSubscriberService($serviceId, $class)
117114
{
118-
$refClass = new \ReflectionClass($class);
119-
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
120-
if (!$refClass->implementsInterface($interface)) {
121-
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $serviceId, $interface));
122-
}
123-
124115
foreach ($class::getSubscribedEvents() as $eventName => $params) {
125116
if (is_string($params)) {
126117
$this->listenerIds[$eventName][] = array($serviceId, $params, 0);
127-
} else {
118+
} elseif (is_string($params[0])) {
128119
$this->listenerIds[$eventName][] = array($serviceId, $params[0], $params[1]);
120+
} else {
121+
foreach ($params as $listener) {
122+
$this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0);
123+
}
129124
}
130125
}
131126
}

0 commit comments

Comments
 (0)
0