8000 merged branch igorw/dic-yaml-without-args (PR #3747) · symfony/symfony@a10fee1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a10fee1

Browse files
committed
merged branch igorw/dic-yaml-without-args (PR #3747)
Commits ------- 24a0d0a [DependencyInjection] Support Yaml calls without arguments Discussion ---------- [DependencyInjection] Support Yaml calls without arguments
2 parents d12e398 + 24a0d0a commit a10fee1

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ private function parseDefinition($id, $service, $file)
198198

199199
if (isset($service['calls'])) {
200200
foreach ($service['calls'] as $call) {
201-
$definition->addMethodCall($call[0], $this->resolveServices($call[1]));
201+
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
202+
$definition->addMethodCall($call[0], $args);
202203
}
203204
}
204205

tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services6.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
class: FooClass
1515
calls:
1616
- [ setBar, [] ]
17+
- [ setBar ]
1718
method_call2:
1819
class: FooClass
1920
calls:

tests/Symfony/Tests/Component/DependencyInjection/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testLoadServices()
113113
$this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag');
114114
$this->assertEquals(array(new Reference('baz'), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag');
115115
$this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag');
116-
$this->assertEquals(array(array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
116+
$this->assertEquals(array(array('setBar', array()), array('setBar', array())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
117117
$this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag');
118118
$this->assertEquals('baz_factory', $services['factory_service']->getFactoryService());
119119

0 commit comments

Comments
 (0)
0