Skip to content

Commit dd2eaf3

Browse files
committed
feature #19326 [Serializer][FrameworkBundle] Add a YAML encoder (dunglas)
This PR was squashed before being merged into the 3.2-dev branch (closes #19326). Discussion ---------- [Serializer][FrameworkBundle] Add a YAML encoder | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | todo Add YAML support to the Serializer. Commits ------- 9366a7d [Serializer][FrameworkBundle] Add a YAML encoder
2 parents 4e15d1d + 75a3828 commit dd2eaf3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2727
use Symfony\Component\Config\FileLocator;
2828
use Symfony\Component\PropertyAccess\PropertyAccessor;
29+
use Symfony\Component\Serializer\Encoder\YamlEncoder;
2930
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
3031
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
3132
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
3233
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
3334
use Symfony\Component\Workflow;
35+
use Symfony\Component\Yaml\Yaml;
3436

3537
/**
3638
* FrameworkExtension.
@@ -1037,6 +1039,12 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
10371039
$definition->addTag('serializer.normalizer', array('priority' => -900));
10381040
}
10391041

1042+
if (class_exists(YamlEncoder::class) && defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
1043+
$definition = $container->register('serializer.encoder.yaml', YamlEncoder::class);
1044+
$definition->setPublic(false);
1045+
$definition->addTag('serializer.encoder');
1046+
}
1047+
10401048
$loader->load('serializer.xml');
10411049
$chainLoader = $container->getDefinition('serializer.mapping.chain_loader');
10421050

0 commit comments

Comments
 (0)