bug #31117 [FrameworkBundle] fix math depth handler configuration (Raulnet)
This PR was merged into the 4.2 branch.
Discussion
----------
[FrameworkBundle] fix math depth handler configuration
| Q | A
| ------------- | ---
| Branch? | 4.2 f
| Bug fix? | no "fix deprecated"
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | https://github.com/symfony/symfony/issues/30998
| License | MIT
| Doc PR |
fix serializer configuration max_deep_handler
Commits
-------
fb9fc804d3
fix math depth handler
This commit is contained in:
commit
097c229d92
@ -1410,7 +1410,9 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
if ($config['max_depth_handler'] ?? false) {
|
||||
$container->getDefinition('serializer.normalizer.object')->addMethodCall('setMaxDepthHandler', [new Reference($config['max_depth_handler'])]);
|
||||
$defaultContext = $container->getDefinition('serializer.normalizer.object')->getArgument(6);
|
||||
$defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
|
||||
$container->getDefinition('serializer.normalizer.object')->replaceArgument(6, $defaultContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,8 @@
|
||||
<argument type="service" id="serializer.property_accessor" />
|
||||
<argument type="service" id="property_info" on-invalid="ignore" />
|
||||
<argument type="service" id="serializer.mapping.class_discriminator_resolver" on-invalid="ignore" />
|
||||
<argument>null</argument>
|
||||
<argument type="collection" />
|
||||
|
||||
<!-- Run after all custom normalizers -->
|
||||
<tag name="serializer.normalizer" priority="-1000" />
|
||||
|
@ -1073,7 +1073,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.name_converter.metadata_aware')->getArgument(1));
|
||||
$this->assertEquals(new Reference('property_info', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $container->getDefinition('serializer.normalizer.object')->getArgument(3));
|
||||
$this->assertEquals(['setCircularReferenceHandler', [new Reference('my.circular.reference.handler')]], $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[0]);
|
||||
$this->assertEquals(['setMaxDepthHandler', [new Reference('my.max.depth.handler')]], $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[1]);
|
||||
$this->assertArrayHasKey('max_depth_handler', $container->getDefinition('serializer.normalizer.object')->getArgument(6));
|
||||
$this->assertEquals($container->getDefinition('serializer.normalizer.object')->getArgument(6)['max_depth_handler'], new Reference('my.max.depth.handler'));
|
||||
}
|
||||
|
||||
public function testRegisterSerializerExtractor()
|
||||
|
@ -110,6 +110,10 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER]) && !\is_callable($this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER])) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid callback found in the "%s" default context option.', self::CIRCULAR_REFERENCE_HANDLER));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user