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