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