Skip to content

Commit 75a3828

Browse files
dunglasfabpot
authored andcommitted
[Serializer][FrameworkBundle] Add a YAML encoder
1 parent b862e7f commit 75a3828

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,12 +26,14 @@
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\Validator\Validation;
3435
use Symfony\Component\Workflow;
36+
use Symfony\Component\Yaml\Yaml;
3537

3638
/**
3739
* FrameworkExtension.
@@ -977,6 +979,12 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
977979
$definition->addTag('serializer.normalizer', array('priority' => -900));
978980
}
979981

982+
if (class_exists(YamlEncoder::class) && defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
983+
$definition = $container->register('serializer.encoder.yaml', YamlEncoder::class);
984+
$definition->setPublic(false);
985+
$definition->addTag('serializer.encoder');
986+
}
987+
980988
$loader->load('serializer.xml');
981989
$chainLoader = $container->getDefinition('serializer.mapping.chain_loader');
982990

0 commit comments

Comments
 (0)