bug #9589 [DependencyInjection] Fixed #9020 - Added support for collections in service#parameters (lavoiesl)
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #9589). Discussion ---------- [DependencyInjection] Fixed #9020 - Added support for collections in service#parameters Disclaimer: I made sure that tests are passing, but I am not sure how to test if it really works. By looking at the code, it should. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9020 | License | MIT | Doc PR | needed Commits ------- 462532e [DependencyInjection] Fixed #9020 - Added support for collections in service#parameters
This commit is contained in:
commit
cf68eb425e
@ -121,10 +121,12 @@
|
||||
|
||||
<xsd:complexType name="property" mixed="true">
|
||||
<xsd:choice minOccurs="0" maxOccurs="1">
|
||||
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="service" type="service" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="argument_type" />
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="key" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="on-invalid" type="xsd:string" />
|
||||
<xsd:attribute name="strict" type="boolean" />
|
||||
|
@ -15,7 +15,7 @@ $container->
|
||||
setFactoryClass('FooClass')->
|
||||
setFactoryMethod('getInstance')->
|
||||
setArguments(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%'), true, new Reference('service_container')))->
|
||||
setProperties(array('foo' => 'bar', 'moo' => new Reference('foo.baz')))->
|
||||
setProperties(array('foo' => 'bar', 'moo' => new Reference('foo.baz'), 'qux' => array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%')))->
|
||||
addMethodCall('setBar', array(new Reference('bar')))->
|
||||
addMethodCall('initialize')->
|
||||
setConfigurator('sc_configure')
|
||||
|
@ -123,6 +123,7 @@ class ProjectServiceContainer extends Container
|
||||
$instance->initialize();
|
||||
$instance->foo = 'bar';
|
||||
$instance->moo = $a;
|
||||
$instance->qux = array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo'));
|
||||
sc_configure($instance);
|
||||
|
||||
return $instance;
|
||||
|
@ -131,6 +131,7 @@ class ProjectServiceContainer extends Container
|
||||
$instance->initialize();
|
||||
$instance->foo = 'bar';
|
||||
$instance->moo = $a;
|
||||
$instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar');
|
||||
sc_configure($instance);
|
||||
|
||||
return $instance;
|
||||
|
@ -19,6 +19,10 @@
|
||||
<argument type="service" id="service_container"/>
|
||||
<property name="foo">bar</property>
|
||||
<property name="moo" type="service" id="foo.baz"/>
|
||||
<property name="qux" type="collection">
|
||||
<property key="%foo%">foo is %foo%</property>
|
||||
<property key="foobar">%foo%</property>
|
||||
</property>
|
||||
<call method="setBar">
|
||||
<argument type="service" id="bar"/>
|
||||
</call>
|
||||
|
@ -12,7 +12,7 @@ services:
|
||||
factory_class: FooClass
|
||||
factory_method: getInstance
|
||||
arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', foobar: '%foo%' }, true, '@service_container']
|
||||
properties: { foo: bar, moo: '@foo.baz' }
|
||||
properties: { foo: bar, moo: '@foo.baz', qux: { '%foo%': 'foo is %foo%', foobar: '%foo%' } }
|
||||
calls:
|
||||
- [setBar, ['@bar']]
|
||||
- [initialize, { }]
|
||||
|
Reference in New Issue
Block a user