Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[DependencyInjection] fixed missing 'factory-class' attribute in XmlD…
…umper 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.
  • Loading branch information
kerdany committed Aug 4, 2014
1 parent 9ac2234 commit 18e3e6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Expand Up @@ -119,6 +119,9 @@ private function addService($definition, $id, \DOMElement $parent)
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());
}
Expand Down
Expand Up @@ -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>
Expand Down Expand Up @@ -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"/>
Expand Down

0 comments on commit 18e3e6f

Please sign in to comment.