blob: d726b0b6a4008a5bc6c5670e711f7c123a0eaae4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<?php
namespace Icinga\Module\Director\Application;
use Icinga\Application\ApplicationBootstrap;
use Icinga\Application\Modules\Module;
use Icinga\Application\Version;
class DependencyChecker
{
/** @var ApplicationBootstrap */
protected $app;
/** @var \Icinga\Application\Modules\Manager */
protected $modules;
public function __construct(ApplicationBootstrap $app)
{
$this->app = $app;
$this->modules = $app->getModuleManager();
}
/**
* @param Module $module
* @return Dependency[]
*/
public function getDependencies(Module $module)
{
$dependencies = [];
$isV290 = version_compare(Version::VERSION, '2.9.0', '>=');
foreach ($module->getDependencies() as $moduleName => $required) {
if ($isV290 && in_array($moduleName, ['ipl', 'reactbundle'], true)) {
continue;
}
$dependency = new Dependency($moduleName, $required);
$dependency->setEnabled($this->modules->hasEnabled($moduleName));
if ($this->modules->hasInstalled($moduleName)) {
$dependency->setInstalledVersion($this->modules->getModule($moduleName, false)->getVersion());
}
$dependencies[] = $dependency;
}
if ($isV290) {
$libs = $this->app->getLibraries();
foreach ($module->getRequiredLibraries() as $libraryName => $required) {
$dependency = new Dependency($libraryName, $required);
if ($libs->has($libraryName)) {
$dependency->setInstalledVersion($libs->get($libraryName)->getVersion());
$dependency->setEnabled();
}
$dependencies[] = $dependency;
}
}
return $dependencies;
}
// if (version_compare(Version::VERSION, '2.9.0', 'ge')) {
// }
/**
* @param Module $module
* @return bool
*/
public function satisfiesDependencies(Module $module)
{
foreach ($this->getDependencies($module) as $dependency) {
if (! $dependency->isSatisfied()) {
return false;
}
}
return true;
}
}
|