EventDispatcher/ContainerAwareEventDispatcher.php
private function addListenerServicePattern($eventPattern, $callback, $priority = 0)
    {
        if (!is_array($callback) || 2 !== count($callback)) {
            throw new \InvalidArgumentException('Expected an array("service", "method") argument');
        }

        $container = $this->container;
        $listenerProvider = function() use ($container, $callback) {
            return array($container->get($callback[0]), $callback[1]);
        };

        $this->addListenerPattern(new LazyListenerPattern($eventPattern, $listenerProvider, $priority));
    }
private function addListenerServicePattern($eventPattern, $callback, $priority = 0)
    {
        if (!is_array($callback) || 2 !== count($callback)) {
            throw new \InvalidArgumentException('Expected an array("service", "method") argument');
        }

        $container = $this->container;
        $listenerProvider = function() use ($container, $callback) {
            return array($container->get($callback[0]), $callback[1]);
        };

        $this->addListenerPattern(new LazyListenerPattern($eventPattern, $listenerProvider, $priority));
    }
private function addListenerServicePattern ( $ eventPattern , $ callback , $ priority = 0 ) { if ( ! is_array ( $ callback ) || 2 !== count ( $ callback ) ) { throw new \ InvalidArgumentException ( 'Expected an array("service", "method") argument' ) ; } $ container = $ this -> container ; $ listenerProvider = function ( ) use ( $ container , $ callback ) { return array ( $ container -> get ( $ callback [ 0 ] ) , $ callback [ 1 ] ) ; } ; $ this -> addListenerPattern ( new LazyListenerPattern ( $ eventPattern , $ listenerProvider , $ priority ) ) ; }
Adds a service as an event listener for all events matching the specified
pattern.

@param string   $eventPattern
@param callback $callback
@param integer  $priority
@throw InvalidArgumentException if the callback is not a service/method tuple
Adds a service as an event listener for all events matching the specified pattern .