bug #23854 [DI] Fix YamlDumper not dumping abstract and autoconfigure (nicolas-grekas)
This PR was merged into the 3.3 branch.
Discussion
----------
[DI] Fix YamlDumper not dumping abstract and autoconfigure
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
685ff0e
[DI] Fix YamlDumper not dumping abstract and autoconfigure
This commit is contained in:
commit
3d54c3b6f4
@ -116,6 +116,14 @@ class YamlDumper extends Dumper
|
||||
$code .= sprintf(" autowiring_types:\n%s", $autowiringTypesCode);
|
||||
}
|
||||
|
||||
if ($definition->isAutoconfigured()) {
|
||||
$code .= " autoconfigure: true\n";
|
||||
}
|
||||
|
||||
if ($definition->isAbstract()) {
|
||||
$code .= " abstract: true\n";
|
||||
}
|
||||
|
||||
if ($definition->isLazy()) {
|
||||
$code .= " lazy: true\n";
|
||||
}
|
||||
|
@ -12,8 +12,10 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
@ -64,6 +66,16 @@ class YamlDumperTest extends TestCase
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services24.yml', $dumper->dump());
|
||||
}
|
||||
|
||||
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($expected, $yaml, $message = '')
|
||||
{
|
||||
$parser = new Parser();
|
||||
|
@ -0,0 +1,14 @@
|
||||
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
synthetic: true
|
||||
foo:
|
||||
autoconfigure: true
|
||||
abstract: true
|
||||
Psr\Container\ContainerInterface:
|
||||
alias: service_container
|
||||
public: false
|
||||
Symfony\Component\DependencyInjection\ContainerInterface:
|
||||
alias: service_container
|
||||
public: false
|
Reference in New Issue
Block a user