src/PimpleAwareEventDispatcher/PimpleAwareEventDispatcher.php
public function addSubscriberService($serviceId, $class)
    {
        $rfc = new \ReflectionClass($class);
        if (!$rfc->implementsInterface('Symfony\Component\EventDispatcher\EventSubscriberInterface')) {
            throw new \InvalidArgumentException(
                "$class must implement Symfony\Component\EventDispatcher\EventSubscriberInterface"
            );
        }

        foreach ($class::getSubscribedEvents() as $eventName => $params) {
            if (is_string($params)) {
                $this->addListenerService($eventName, array($serviceId, $params), 0);
            } elseif (is_string($params[0])) {
                $this->addListenerService($eventName, array($serviceId, $params[0]), isset($params[1]) ? $params[1] : 0);
            } else {
                foreach ($params as $listener) {
                    $this->addListenerService($eventName, array($serviceId, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
                }
            }
        }
    }
public function addSubscriberService($serviceId, $class)
    {
        $rfc = new \ReflectionClass($class);
        if (!$rfc->implementsInterface('Symfony\Component\EventDispatcher\EventSubscriberInterface')) {
            throw new \InvalidArgumentException(
                "$class must implement Symfony\Component\EventDispatcher\EventSubscriberInterface"
            );
        }

        foreach ($class::getSubscribedEvents() as $eventName => $params) {
            if (is_string($params)) {
                $this->addListenerService($eventName, array($serviceId, $params), 0);
            } elseif (is_string($params[0])) {
                $this->addListenerService($eventName, array($serviceId, $params[0]), isset($params[1]) ? $params[1] : 0);
            } else {
                foreach ($params as $listener) {
                    $this->addListenerService($eventName, array($serviceId, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
                }
            }
        }
    }
public function addSubscriberService ( $ serviceId , $ class ) { $ rfc = new \ ReflectionClass ( $ class ) ; if ( ! $ rfc -> implementsInterface ( 'Symfony\Component\EventDispatcher\EventSubscriberInterface' ) ) { throw new \ InvalidArgumentException ( "$class must implement Symfony\Component\EventDispatcher\EventSubscriberInterface" ) ; } foreach ( $ class :: getSubscribedEvents ( ) as $ eventName => $ params ) { if ( is_string ( $ params ) ) { $ this -> addListenerService ( $ eventName , array ( $ serviceId , $ params ) , 0 ) ; } elseif ( is_string ( $ params [ 0 ] ) ) { $ this -> addListenerService ( $ eventName , array ( $ serviceId , $ params [ 0 ] ) , isset ( $ params [ 1 ] ) ? $ params [ 1 ] : 0 ) ; } else { foreach ( $ params as $ listener ) { $ this -> addListenerService ( $ eventName , array ( $ serviceId , $ listener [ 0 ] ) , isset ( $ listener [ 1 ] ) ? $ listener [ 1 ] : 0 ) ; } } } }
Adds a service as event subscriber

@param string $serviceId The service ID of the subscriber service
@param string $class The service's class name (which must implement EventSubscriberInterface)
Adds a service as event subscriber