| Conditions | 4 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 30 | public function process(ContainerBuilder $container) |
|
| 15 | { |
||
| 16 | 30 | if (!$container->has('jms_serializer.metadata.doctrine_type_driver')) { |
|
| 17 | 15 | return; |
|
| 18 | } |
||
| 19 | |||
| 20 | 15 | $handler = $container->register('cruds.jms.doctrine_associations_handler', JmsDoctrineHandler::class); |
|
| 21 | |||
| 22 | //fixme: JMS utilizes only public handlers for lazyness |
||
| 23 | 15 | $handler->setPublic(true); |
|
| 24 | 15 | $handler->addArgument(new Reference('doctrine')); |
|
| 25 | |||
| 26 | 15 | $formats = ['json', 'xml', 'array']; |
|
| 27 | $directions = [ |
||
| 28 | 15 | 'serialization' => 'serializeRelation', |
|
| 29 | 'deserialization' => 'deserializeRelation', |
||
| 30 | ]; |
||
| 31 | 15 | $type = JmsDoctrineHandler::TYPE; |
|
| 32 | 15 | $name = 'jms_serializer.handler'; |
|
| 33 | |||
| 34 | 15 | foreach ($formats as $format) { |
|
| 35 | 15 | foreach ($directions as $direction => $method) { |
|
| 36 | 15 | $handler->addTag( |
|
| 37 | 15 | $name, |
|
| 38 | [ |
||
| 39 | 15 | 'type' => $type, |
|
| 40 | 15 | 'direction' => $direction, |
|
| 41 | 15 | 'format' => $format, |
|
| 42 | 15 | 'method' => $method, |
|
| 43 | ] |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | 15 | } |
|
| 48 | } |
||
| 49 |