Conditions | 4 |
Paths | 8 |
Total Lines | 29 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
25 | 2 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
26 | { |
||
27 | /* @var \Doctrine\ODM\MongoDB\DocumentManager $dm */ |
||
28 | 2 | $config = $container->get('config'); |
|
29 | 2 | $config = $config['slm_queue']['queues'][$requestedName] ?? []; |
|
30 | 2 | $dm = $container->get('Core/DocumentManager'); |
|
31 | |||
32 | // @codeCoverageIgnoreStart |
||
33 | if (isset($config['dns'])) { |
||
34 | $client = new \MongoDB\Client($config['dns']); |
||
35 | } else { |
||
36 | $client = $dm->getConnection()->getMongoClient()->getClient(); |
||
37 | } |
||
38 | // @codeCoverageIgnoreEnd |
||
39 | |||
40 | 2 | if (!isset($config['db'])) { |
|
41 | 1 | $config['db'] = $dm->getConfiguration()->getDefaultDB(); |
|
42 | } |
||
43 | |||
44 | 2 | if (!isset($config['collection'])) { |
|
45 | 1 | $config['collection'] = 'core.queue'; |
|
46 | } |
||
47 | |||
48 | 2 | $collection = $client->selectCollection($config['db'], $config['collection']); |
|
49 | 2 | $jobPlugins = $container->get(JobPluginManager::class); |
|
50 | |||
51 | 2 | $service = new MongoQueue($collection, $requestedName, $jobPlugins); |
|
52 | |||
53 | 2 | return $service; |
|
54 | } |
||
56 |