From cd989f9c3aff968e19a3aeabc4eb9085787a6673 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:43:12 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Application/DependencyChecker.php | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 library/Director/Application/DependencyChecker.php (limited to 'library/Director/Application/DependencyChecker.php') diff --git a/library/Director/Application/DependencyChecker.php b/library/Director/Application/DependencyChecker.php new file mode 100644 index 0000000..d726b0b --- /dev/null +++ b/library/Director/Application/DependencyChecker.php @@ -0,0 +1,73 @@ +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; + } +} -- cgit v1.2.3