public function addSubscriber(EventSubscriber $eventSubscriber)
    {
        $listeners = $eventSubscriber->getEvents();

        foreach($listeners as $listener => $data)
        {
            if (is_array($data)) {
                $data = new SubscriberConfiguration($data[0], $data[1] ?? self::USE_ALL, $data[2] ?? 100);
            }

            if (!$data instanceof SubscriberConfiguration) {
                throw new \InvalidArgumentException(
                    'SubscriberConfiguration for ' . $listener . ' in ' . get_class($eventSubscriber) . ' is invalid!'
                );
            }

            // horrible hack due to array not being a callable in this case ... whut?
            $listenerCallable = function($events) use ($eventSubscriber, $listener) {
                $eventSubscriber->{$listener}($events);
            };

            $this->addWeightedListener(
                $listenerCallable,
                $data->getUseType(),
                $data->getWeight(),
                ...$data->getEvents()
            );
        }
    }
public function addSubscriber(EventSubscriber $eventSubscriber)
    {
        $listeners = $eventSubscriber->getEvents();

        foreach($listeners as $listener => $data)
        {
            if (is_array($data)) {
                $data = new SubscriberConfiguration($data[0], $data[1] ?? self::USE_ALL, $data[2] ?? 100);
            }

            if (!$data instanceof SubscriberConfiguration) {
                throw new \InvalidArgumentException(
                    'SubscriberConfiguration for ' . $listener . ' in ' . get_class($eventSubscriber) . ' is invalid!'
                );
            }

            // horrible hack due to array not being a callable in this case ... whut?
            $listenerCallable = function($events) use ($eventSubscriber, $listener) {
                $eventSubscriber->{$listener}($events);
            };

            $this->addWeightedListener(
                $listenerCallable,
                $data->getUseType(),
                $data->getWeight(),
                ...$data->getEvents()
            );
        }
    }
public function addSubscriber ( EventSubscriber $ eventSubscriber ) { $ listeners = $ eventSubscriber -> getEvents ( ) ; foreach ( $ listeners as $ listener => $ data ) { if ( is_array ( $ data ) ) { $ data = new SubscriberConfiguration ( $ data [ 0 ] , $ data [ 1 ] ?? self :: USE_ALL , $ data [ 2 ] ?? 100 ) ; } if ( ! $ data instanceof SubscriberConfiguration ) { throw new \ InvalidArgumentException ( 'SubscriberConfiguration for ' . $ listener . ' in ' . get_class ( $ eventSubscriber ) . ' is invalid!' ) ; } // horrible hack due to array not being a callable in this case ... whut? $ listenerCallable = function ( $ events ) use ( $ eventSubscriber , $ listener ) { $ eventSubscriber -> { $ listener } ( $ events ) ; } ; $ this -> addWeightedListener ( $ listenerCallable , $ data -> getUseType ( ) , $ data -> getWeight ( ) , ... $ data -> getEvents ( ) ) ; } }
Adds an event subscriber that listens on the specified events.
Internally this will convert all handlers to listeners.

@param EventSubscriber $eventSubscriber The subscriber
@throws \InvalidArgumentException

@api
Adds an event subscriber that listens on the specified events . Internally this will convert all handlers to listeners .