Skip to content

Commit

Permalink
[DependencyInjection] Support Yaml calls without arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed Mar 31, 2012
1 parent 72e82eb commit 24a0d0a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Expand Up @@ -196,7 +196,8 @@ private function parseDefinition($id, $service, $file)

if (isset($service['calls'])) {
foreach ($service['calls'] as $call) {
$definition->addMethodCall($call[0], $this->resolveServices($call[1]));
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
$definition->addMethodCall($call[0], $args);
}
}

Expand Down
Expand Up @@ -14,6 +14,7 @@ services:
class: FooClass
calls:
- [ setBar, [] ]
- [ setBar ]
method_call2:
class: FooClass
calls:
Expand Down
Expand Up @@ -113,7 +113,7 @@ public function testLoadServices()
$this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag');
$this->assertEquals(array(new Reference('baz'), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag');
$this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag');
$this->assertEquals(array(array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
$this->assertEquals(array(array('setBar', array()), array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
$this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag');
$this->assertEquals('baz_factory', $services['factory_service']->getFactoryService());

Expand Down

0 comments on commit 24a0d0a

Please sign in to comment.