| Conditions | 4 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function process(ContainerBuilder $container) |
||
| 17 | { |
||
| 18 | if (!$container->has('serializer') || $container->hasAlias('serializer')) { |
||
| 19 | |||
| 20 | return; |
||
| 21 | } |
||
| 22 | |||
| 23 | $class = $container->getDefinition('serializer')->getClass(); |
||
| 24 | if (!in_array(SerializerInterface::class, class_implements($class), true)) { |
||
| 25 | |||
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | $handler = new Definition(CircularReferenceHandler::class); |
||
| 30 | $handler->setArguments([new Reference('doctrine')]); |
||
| 31 | |||
| 32 | $normalizer = new DefinitionDecorator('serializer.normalizer.object'); |
||
| 33 | $normalizer->addTag('serializer.normalizer', ['priority' => -100]); |
||
| 34 | $normalizer->addMethodCall('setCircularReferenceHandler', [[$handler, 'handle']]); |
||
| 35 | |||
| 36 | $container->setDefinition('cruds.object_normalizer', $normalizer); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |