| Conditions | 8 |
| Paths | 11 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 72 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function process(ContainerBuilder $container) |
||
| 30 | { |
||
| 31 | if (!$container->hasDefinition('fos_elastica.elastica_to_model_transformer.collection')) { |
||
| 32 | return; |
||
| 33 | } |
||
| 34 | |||
| 35 | $transformers = []; |
||
| 36 | |||
| 37 | foreach ($container->findTaggedServiceIds('fos_elastica.elastica_to_model_transformer') as $id => $tags) { |
||
| 38 | foreach ($tags as $tag) { |
||
| 39 | if (empty($tag['index']) || empty($tag['type'])) { |
||
| 40 | throw new InvalidArgumentException('The Transformer must have both a type and an index defined.'); |
||
| 41 | } |
||
| 42 | |||
| 43 | $transformers[$tag['index']][$tag['type']] = new Reference($id); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | foreach ($transformers as $index => $indexTransformers) { |
||
| 48 | if (!$container->hasDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index))) { |
||
| 49 | continue; |
||
| 50 | } |
||
| 51 | |||
| 52 | $index = $container->getDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index)); |
||
| 53 | $index->replaceArgument(0, $indexTransformers); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 |