Conditions | 8 |
Paths | 11 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 8.7021 |
1 | <?php |
||
20 | 12 | public function process(ContainerBuilder $container) |
|
21 | { |
||
22 | 12 | if (!$container->hasDefinition('fos_elastica.elastica_to_model_transformer.collection')) { |
|
23 | return; |
||
24 | } |
||
25 | |||
26 | 12 | $transformers = array(); |
|
27 | |||
28 | 12 | foreach ($container->findTaggedServiceIds('fos_elastica.elastica_to_model_transformer') as $id => $tags) { |
|
29 | 8 | foreach ($tags as $tag) { |
|
30 | 8 | 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 | 8 | $transformers[$tag['index']][$tag['type']] = new Reference($id); |
|
35 | 8 | } |
|
36 | 12 | } |
|
37 | |||
38 | 12 | foreach ($transformers as $index => $indexTransformers) { |
|
39 | 8 | if (!$container->hasDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index))) { |
|
40 | 8 | continue; |
|
41 | } |
||
42 | |||
43 | $index = $container->getDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index)); |
||
44 | $index->replaceArgument(0, $indexTransformers); |
||
45 | 12 | } |
|
46 | 12 | } |
|
47 | } |
||
48 |