[DI] Fix dumping abstract with YamlDumper
This commit is contained in:
parent
5fad797f6b
commit
c396e8cb9c
|
@ -104,6 +104,10 @@ class YamlDumper extends Dumper
|
||||||
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
|
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($definition->isAbstract()) {
|
||||||
|
$code .= " abstract: true\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ($definition->isLazy()) {
|
if ($definition->isLazy()) {
|
||||||
$code .= " lazy: true\n";
|
$code .= " lazy: true\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
|
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class YamlDumperTest extends TestCase
|
class YamlDumperTest extends TestCase
|
||||||
|
@ -77,6 +79,16 @@ class YamlDumperTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDumpLoad()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||||
|
$loader->load('services_dump_load.yml');
|
||||||
|
|
||||||
|
$dumper = new YamlDumper($container);
|
||||||
|
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
|
||||||
|
}
|
||||||
|
|
||||||
private function assertEqualYamlStructure($yaml, $expected, $message = '')
|
private function assertEqualYamlStructure($yaml, $expected, $message = '')
|
||||||
{
|
{
|
||||||
$this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message);
|
$this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message);
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
services:
|
||||||
|
foo:
|
||||||
|
abstract: true
|
Reference in New Issue