@@ -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