@@ -107,25 +107,20 @@ public function getListeners($eventName = null)
107
107
/**
108
108
* Adds a service as event subscriber
109
109
*
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
- *
113
110
* @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)
115
112
*/
116
113
public function addSubscriberService ($ serviceId , $ class )
117
114
{
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
-
124
115
foreach ($ class ::getSubscribedEvents () as $ eventName => $ params ) {
125
116
if (is_string ($ params )) {
126
117
$ this ->listenerIds [$ eventName ][] = array ($ serviceId , $ params , 0 );
127
- } else {
118
+ } elseif ( is_string ( $ params [ 0 ])) {
128
119
$ 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
+ }
129
124
}
130
125
}
131
126
}
0 commit comments