Skip to content

Commit

Permalink
move wiring of the property info extractor to the ObjectNormalizer
Browse files Browse the repository at this point in the history
The PropertyNormalizer does not handle a property info extractor. It looks
like the argument was accidentally added to instead of the ObjectNormalizer
in #52917.
  • Loading branch information
xabbuh committed Apr 30, 2024
1 parent 65640a7 commit 87b6700
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions DependencyInjection/FrameworkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1854,18 +1854,19 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
$container->setParameter('serializer.default_context', $defaultContext);
}

$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
$context = [];

if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
$context = ($arguments[6] ?? $defaultContext) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
$context += ($arguments[6] ?? $defaultContext) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
$container->getDefinition('serializer.normalizer.object')->setArgument(5, null);
$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
}

if ($config['max_depth_handler'] ?? false) {
$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
$context = ($arguments[6] ?? $defaultContext) + ['max_depth_handler' => new Reference($config['max_depth_handler'])];
$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
$context += ($arguments[6] ?? $defaultContext) + ['max_depth_handler' => new Reference($config['max_depth_handler'])];
}

$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
}

private function registerPropertyInfoConfiguration(ContainerBuilder $container, PhpFileLoader $loader)
Expand Down
3 changes: 2 additions & 1 deletion Resources/config/serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
service('property_info')->ignoreOnInvalid(),
service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(),
null,
null,
service('property_info')->ignoreOnInvalid(),
])
->tag('serializer.normalizer', ['priority' => -1000])

Expand All @@ -138,7 +140,6 @@
service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(),
null,
[],
service('property_info')->ignoreOnInvalid(),
])

->alias(PropertyNormalizer::class, 'serializer.normalizer.property')
Expand Down

0 comments on commit 87b6700

Please sign in to comment.