Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 966f387

Browse files
committed
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
2 parents 657f7ec + 40f60ec commit 966f387

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ private function addService($definition, $id, \DOMElement $parent)
191191
$service->appendChild($factory);
192192
}
193193

194+
if ($definition->isAbstract()) {
195+
$service->setAttribute('abstract', 'true');
196+
}
197+
194198
if ($callable = $definition->getConfigurator()) {
195199
$configurator = $this->document->createElement('configurator');
196200

src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,12 @@ public function testDumpInlinedServices()
184184

185185
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services21.xml'), $dumper->dump());
186186
}
187+
188+
public function testDumpAbstractServices()
189+
{
190+
$container = include self::$fixturesPath.'/containers/container_abstract.php';
191+
$dumper = new XmlDumper($container);
192+
193+
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services_abstract.xml'), $dumper->dump());
194+
}
187195
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\ContainerBuilder;
4+
5+
$container = new ContainerBuilder();
6+
7+
$container
8+
->register('foo', 'Foo')
9+
->setAbstract(true)
10+
;
11+
12+
return $container;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<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">
3+
<services>
4+
<service id="foo" class="Foo" abstract="true"/>
5+
</services>
6+
</container>

0 commit comments

Comments
 (0)