|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bdf\PrimeBundle; |
|
4
|
|
|
|
|
5
|
|
|
use Bdf\Prime\Locatorizable; |
|
6
|
|
|
use Bdf\Prime\MongoDB\Collection\MongoCollectionLocator; |
|
|
|
|
|
|
7
|
|
|
use Bdf\Prime\MongoDB\Mongo; |
|
|
|
|
|
|
8
|
|
|
use Bdf\Prime\ServiceLocator; |
|
9
|
|
|
use Bdf\PrimeBundle\DependencyInjection\Compiler\IgnorePrimeAnnotationsPass; |
|
10
|
|
|
use Bdf\PrimeBundle\DependencyInjection\Compiler\PrimeConnectionFactoryPass; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
12
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* PrimeBundle. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Seb |
|
18
|
|
|
*/ |
|
19
|
|
|
class PrimeBundle extends Bundle |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* {@inheritDoc} |
|
23
|
|
|
*/ |
|
24
|
11 |
|
public function boot() |
|
25
|
|
|
{ |
|
26
|
11 |
|
if ($this->container->getParameter('prime.locatorizable')) { |
|
27
|
11 |
|
Locatorizable::configure(function () { |
|
28
|
2 |
|
return $this->container->get('prime'); |
|
29
|
11 |
|
}); |
|
30
|
|
|
|
|
31
|
11 |
|
if (class_exists(Mongo::class)) { |
|
32
|
|
|
Mongo::configure(function () { |
|
33
|
|
|
return $this->container->get(MongoCollectionLocator::class); |
|
34
|
|
|
}); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritDoc} |
|
41
|
|
|
*/ |
|
42
|
8 |
|
public function build(ContainerBuilder $container) |
|
43
|
|
|
{ |
|
44
|
8 |
|
$container->addCompilerPass(new PrimeConnectionFactoryPass()); |
|
45
|
8 |
|
$container->addCompilerPass(new IgnorePrimeAnnotationsPass()); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritDoc} |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function shutdown() |
|
52
|
|
|
{ |
|
53
|
1 |
|
if ($this->container->initialized('prime')) { |
|
54
|
|
|
/** @var ServiceLocator $prime */ |
|
55
|
|
|
$prime = $this->container->get('prime'); |
|
56
|
|
|
|
|
57
|
|
|
// Clear circle references |
|
58
|
|
|
$prime->clearRepositories(); |
|
59
|
|
|
|
|
60
|
|
|
// Close all loaded connections |
|
61
|
|
|
foreach ($prime->connections() as $connection) { |
|
62
|
|
|
$connection->close(); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// Always unconfigure locator, because it's configured even if prime is not initialized |
|
67
|
1 |
|
if ($this->container->getParameter('prime.locatorizable')) { |
|
68
|
1 |
|
Locatorizable::configure(null); |
|
69
|
|
|
|
|
70
|
1 |
|
if (class_exists(Mongo::class)) { |
|
71
|
|
|
Mongo::configure(null); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths