From 0a638f535229f6e86445b6eb8a8b86d18d92a7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 15 Mar 2017 17:25:41 +0100 Subject: [PATCH] [FrameworkBundle][Serializer] Add option to register a "circular_reference_handler" --- .../FrameworkBundle/DependencyInjection/Configuration.php | 1 + .../DependencyInjection/FrameworkExtension.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index ae2250e3d44c..94d9e4566628 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -686,6 +686,7 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode) ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end() ->scalarNode('cache')->end() ->scalarNode('name_converter')->end() + ->scalarNode('circular_reference_handler')->end() ->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index cf6ba7a0c2e4..9c98f795eb75 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1281,6 +1281,10 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder if (isset($config['name_converter']) && $config['name_converter']) { $container->getDefinition('serializer.normalizer.object')->replaceArgument(1, new Reference($config['name_converter'])); } + + if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) { + $container->getDefinition('serializer.normalizer.object')->addMethodCall('setCircularReferenceHandler', array(new Reference($config['circular_reference_handler']))); + } } /**