Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug #22901 Fix missing abstract key in XmlDumper (weaverryan)
This PR was merged into the 2.7 branch.

Discussion
----------

Fix missing abstract key in XmlDumper

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | n/a

Unless I'm missing something, the abstract key was missing in the XmlDumper. I noticed it when using `debug:container some_abstract_service` and was seeing "no" for abstract.

When this merges to 3.3, the `services-abstract.xml` will need to change to this:

```xml
<?xml version="1.0" encoding="utf-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
  <services>
    <service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" synthetic="true"/>
    <service id="foo" class="Foo" abstract="true"/>
    <service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
    <service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
  </services>
</container>
```

Commits
-------

40f60ec Fixing missing abstract attribute in XmlDumper
  • Loading branch information
fabpot committed May 25, 2017
2 parents 657f7ec + 40f60ec commit 966f387
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Expand Up @@ -191,6 +191,10 @@ private function addService($definition, $id, \DOMElement $parent)
$service->appendChild($factory);
}

if ($definition->isAbstract()) {
$service->setAttribute('abstract', 'true');
}

if ($callable = $definition->getConfigurator()) {
$configurator = $this->document->createElement('configurator');

Expand Down
Expand Up @@ -184,4 +184,12 @@ public function testDumpInlinedServices()

$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services21.xml'), $dumper->dump());
}

public function testDumpAbstractServices()
{
$container = include self::$fixturesPath.'/containers/container_abstract.php';
$dumper = new XmlDumper($container);

$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services_abstract.xml'), $dumper->dump());
}
}
@@ -0,0 +1,12 @@
<?php

use Symfony\Component\DependencyInjection\ContainerBuilder;

$container = new ContainerBuilder();

$container
->register('foo', 'Foo')
->setAbstract(true)
;

return $container;
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="foo" class="Foo" abstract="true"/>
</services>
</container>

0 comments on commit 966f387

Please sign in to comment.