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

Skip to content

Commit ad81c6e

Browse files
committed
Fixing missing abstract attribute in XmlDumper
Caused mis-reporting of abstract key (always no) in debug:container
1 parent 49d6604 commit ad81c6e

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)