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