[DependencyInjection] fixed missing 'factory-class' attribute in XmlDumper output
Symfony\Component\DependencyInjection\Dumper\XmlDumper didn't write 'factory-class' XML attribute for definitions on which setFactoryClass() was called. This caused the Container[Builder] to throw an exception when the relevant service is being requested/initiated after loading the dumped XML: `Uncaught Exception Symfony\Component\DependencyInjection\Exception\RuntimeException: "Cannot create service "xxx" from factory method without a factory service or factory class." at /<path>/<to>/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php` Fixed the problem, and updated the relevant test fixture.
This commit is contained in:
parent
9ac2234eb8
commit
18e3e6fe20
|
@ -119,6 +119,9 @@ class XmlDumper extends Dumper
|
|||
if ($definition->getFactoryMethod()) {
|
||||
$service->setAttribute('factory-method', $definition->getFactoryMethod());
|
||||
}
|
||||
if ($definition->getFactoryClass()) {
|
||||
$service->setAttribute('factory-class', $definition->getFactoryClass());
|
||||
}
|
||||
if ($definition->getFactoryService()) {
|
||||
$service->setAttribute('factory-service', $definition->getFactoryService());
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parameter key="foo">bar</parameter>
|
||||
</parameters>
|
||||
<services>
|
||||
<service id="foo" class="FooClass" factory-method="getInstance">
|
||||
<service id="foo" class="FooClass" factory-method="getInstance" factory-class="FooClass">
|
||||
<tag name="foo" foo="foo"/>
|
||||
<tag name="foo" bar="bar"/>
|
||||
<argument>foo</argument>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<argument>%foo_bar%</argument>
|
||||
<configurator service="foo.baz" method="configure"/>
|
||||
</service>
|
||||
<service id="foo.baz" class="%baz_class%" factory-method="getInstance">
|
||||
<service id="foo.baz" class="%baz_class%" factory-method="getInstance" factory-class="%baz_class%">
|
||||
<configurator class="%baz_class%" method="configureStatic1"/>
|
||||
</service>
|
||||
<service id="foo_bar" class="%foo_class%" scope="prototype"/>
|
||||
|
|
Reference in New Issue