merged branch igorw/dic-yaml-without-args (PR #3747)
Commits
-------
24a0d0a
[DependencyInjection] Support Yaml calls without arguments
Discussion
----------
[DependencyInjection] Support Yaml calls without arguments
This commit is contained in:
commit
a10fee16c1
@ -198,7 +198,8 @@ class YamlFileLoader extends FileLoader
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ services:
|
||||
class: FooClass
|
||||
calls:
|
||||
- [ setBar, [] ]
|
||||
- [ setBar ]
|
||||
method_call2:
|
||||
class: FooClass
|
||||
calls:
|
||||
|
@ -113,7 +113,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$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());
|
||||
|
||||
|
Reference in New Issue
Block a user