diff --git a/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php b/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php index 65152c889415..fc94368cd984 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php @@ -65,40 +65,6 @@ public function addListener($eventNames, $listener, $priority = 0) parent::addListener($eventNames, $listener, $priority); } - /** - * {@inheritDoc} - * - * @throws \RuntimeException if the service does not exist - * @throws \RuntimeException if the listener service method is not callable - */ - public function addListenerService($eventNames, $serviceId, $priority = 0) - { - $error = null; - - if (!$this->container->has($serviceId)) { - $error = sprintf('The container has no service "%s".', $serviceId); - } else { - $listener = $this->container->get($serviceId); - if (!$listener instanceof \Closure) { - foreach ((array) $eventNames as $method) { - if (!is_callable(array($listener, $method))) { - $error = sprintf('The event method "%s()" is not callable on the service "%s".', $method, $serviceId); - break; - } - } - } - } - - if (null !== $error) { - if (null !== $this->logger) { - $this->logger->err($error); - } - throw new \RuntimeException($error); - } - - parent::addListenerService($eventNames, $serviceId, $priority); - } - /** * {@inheritDoc} */ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Debug/TraceableEventDispactherTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Debug/TraceableEventDispactherTest.php index ea56b1441968..54f1872b8f7b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Debug/TraceableEventDispactherTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Debug/TraceableEventDispactherTest.php @@ -26,45 +26,4 @@ public function testThrowsAnExceptionWhenAListenerMethodIsNotCallable() $dispatcher = new TraceableEventDispatcher($container); $dispatcher->addListener('onFooEvent', new \stdClass()); } - - /** - * @expectedException \RuntimeException - */ - public function testThrowsAnExceptionWhenAListenerServiceIsNotFound() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container - ->expects($this->once()) - ->method('has') - ->with($this->equalTo('listener.service')) - ->will($this->returnValue(false)) - ; - - $dispatcher = new TraceableEventDispatcher($container); - - $dispatcher->addListenerService('onFooEvent', 'listener.service'); - } - - /** - * @expectedException \RuntimeException - */ - public function testThrowsAnExceptionWhenAListenerServiceMethodIsNotCallable() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container - ->expects($this->once()) - ->method('has') - ->with($this->equalTo('listener.service')) - ->will($this->returnValue(true)) - ; - $container - ->expects($this->once()) - ->method('get') - ->with($this->equalTo('listener.service')) - ->will($this->returnValue(new \stdClass())) - ; - - $dispatcher = new TraceableEventDispatcher($container); - $dispatcher->addListenerService('onFooEvent', 'listener.service'); - } }