Conditions | 5 |
Paths | 5 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
21 | 4 | public function process(ContainerBuilder $container) |
|
22 | { |
||
23 | 4 | if (!$container->has('gbprod.algolia_specification_handler')) { |
|
24 | 1 | throw new \Exception('Missing gbprod.algolia_specification_handler definition'); |
|
25 | } |
||
26 | |||
27 | 3 | $handler = $container->findDefinition('gbprod.algolia_specification_handler'); |
|
28 | |||
29 | 3 | $factories = $container->findTaggedServiceIds('algolia.query_factory'); |
|
30 | |||
31 | 3 | foreach ($factories as $id => $tags) { |
|
32 | 2 | foreach ($tags as $attributes) { |
|
33 | 2 | if (!isset($attributes['specification'])) { |
|
34 | 1 | throw new \Exception( |
|
35 | 1 | 'The algolia.query_factory tag must always have a "specification" attribute' |
|
36 | ); |
||
37 | } |
||
38 | |||
39 | 1 | $handler->addMethodCall( |
|
40 | 1 | 'registerFactory', |
|
41 | 1 | [$attributes['specification'], new Reference($id)] |
|
42 | ); |
||
43 | } |
||
44 | } |
||
45 | 2 | } |
|
46 | } |
||
47 |