Skip to content

Commit

Permalink
bug #54791 [FrameworkBundle] move wiring of the property info extract…
Browse files Browse the repository at this point in the history
…or to the ObjectNormalizer (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle] move wiring of the property info extractor to the ObjectNormalizer

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

The PropertyNormalizer does not handle a property info extractor. It looks like the argument was accidentally added to instead of the ObjectNormalizer in #52917.

Commits
-------

518bc283a0 move wiring of the property info extractor to the ObjectNormalizer
  • Loading branch information
chalasr committed May 1, 2024
2 parents 9e62703 + 87b6700 commit 65e7423
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 65e7423

Please sign in to comment.