| Conditions | 5 |
| Paths | 8 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function process(ContainerBuilder $container) |
||
| 12 | { |
||
| 13 | $sourceManager = $container->getDefinition('dtc_grid.manager.source'); |
||
| 14 | |||
| 15 | if ($container->has('doctrine')) { |
||
| 16 | $sourceManager->addMethodCall('setRegistry', [new Reference('doctrine')]); |
||
| 17 | } |
||
| 18 | |||
| 19 | if ($container->has('doctrine_mongodb')) { |
||
| 20 | $sourceManager->addMethodCall('setMongodbRegistry', [new Reference('doctrine_mongodb')]); |
||
| 21 | } |
||
| 22 | |||
| 23 | // Add each worker to workerManager, make sure each worker has instance to work |
||
| 24 | foreach ($container->findTaggedServiceIds('dtc_grid.source') as $id => $attributes) { |
||
| 25 | $gridSourceDefinition = $container->getDefinition($id); |
||
| 26 | $class = $gridSourceDefinition->getClass(); |
||
| 27 | |||
| 28 | $refClass = new \ReflectionClass($class); |
||
| 29 | $interface = 'Dtc\GridBundle\Grid\Source\GridSourceInterface'; |
||
| 30 | |||
| 31 | if (!$refClass->implementsInterface($interface)) { |
||
| 32 | throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); |
||
| 33 | } |
||
| 34 | |||
| 35 | $gridSourceDefinition->addMethodCall('setId', array($id)); |
||
| 36 | $sourceManager->addMethodCall('add', [$id, new Reference($id)]); |
||
| 37 | } |
||
| 40 |