mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 14:54:24 +02:00
parent
745674dbe4
commit
6e382093f4
@ -9,10 +9,8 @@ use LogicException;
|
|||||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||||
use Icinga\Authentication\User\UserBackend;
|
use Icinga\Authentication\User\UserBackend;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Data\ResourceFactory;
|
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\NotReadableError;
|
use Icinga\Exception\NotReadableError;
|
||||||
use Icinga\Application\Logger;
|
|
||||||
use Icinga\Util\Translator;
|
use Icinga\Util\Translator;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
|
||||||
@ -141,7 +139,11 @@ abstract class ApplicationBootstrap
|
|||||||
$this->baseDir = $baseDir;
|
$this->baseDir = $baseDir;
|
||||||
$this->appDir = $baseDir . '/application';
|
$this->appDir = $baseDir . '/application';
|
||||||
$this->vendorDir = $baseDir . '/library/vendor';
|
$this->vendorDir = $baseDir . '/library/vendor';
|
||||||
$this->libDir = realpath(__DIR__ . '/../..');
|
if (substr(__DIR__, 0, 8) === 'phar:///') {
|
||||||
|
$this->libDir = dirname(dirname(__DIR__));
|
||||||
|
} else {
|
||||||
|
$this->libDir = realpath(__DIR__ . '/../..');
|
||||||
|
}
|
||||||
|
|
||||||
$this->setupAutoloader();
|
$this->setupAutoloader();
|
||||||
|
|
||||||
@ -403,14 +405,37 @@ abstract class ApplicationBootstrap
|
|||||||
*/
|
*/
|
||||||
protected function setupModuleManager()
|
protected function setupModuleManager()
|
||||||
{
|
{
|
||||||
|
$paths = $this->getAvailableModulePaths();
|
||||||
$this->moduleManager = new ModuleManager(
|
$this->moduleManager = new ModuleManager(
|
||||||
$this,
|
$this,
|
||||||
$this->configDir . '/enabledModules',
|
$this->configDir . '/enabledModules',
|
||||||
explode(':', $this->config->get('global', 'module_path', $this->baseDir . '/modules'))
|
$paths
|
||||||
);
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getAvailableModulePaths()
|
||||||
|
{
|
||||||
|
$paths = array();
|
||||||
|
$configured = $this->config->get('global', 'module_path', $this->baseDir . '/modules');
|
||||||
|
$nextIsPhar = false;
|
||||||
|
foreach (explode(':', $configured) as $path) {
|
||||||
|
if ($path === 'phar') {
|
||||||
|
$nextIsPhar = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($nextIsPhar) {
|
||||||
|
$nextIsPhar = false;
|
||||||
|
$paths[] = 'phar:' . $path;
|
||||||
|
} else {
|
||||||
|
$paths[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $paths;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all enabled modules
|
* Load all enabled modules
|
||||||
*
|
*
|
||||||
|
@ -141,6 +141,7 @@ class Manager
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (($dh = opendir($this->enableDir)) !== false) {
|
if (($dh = opendir($this->enableDir)) !== false) {
|
||||||
|
$isPhar = substr($this->enableDir, 0, 8) === 'phar:///';
|
||||||
$this->enabledDirs = array();
|
$this->enabledDirs = array();
|
||||||
while (($file = readdir($dh)) !== false) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if ($file[0] === '.' || $file === 'README') {
|
if ($file[0] === '.' || $file === 'README') {
|
||||||
@ -148,7 +149,7 @@ class Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
$link = $this->enableDir . DIRECTORY_SEPARATOR . $file;
|
$link = $this->enableDir . DIRECTORY_SEPARATOR . $file;
|
||||||
if (! is_link($link)) {
|
if (! $isPhar && ! is_link($link)) {
|
||||||
Logger::warning(
|
Logger::warning(
|
||||||
'Found invalid module in enabledModule directory "%s": "%s" is not a symlink',
|
'Found invalid module in enabledModule directory "%s": "%s" is not a symlink',
|
||||||
$this->enableDir,
|
$this->enableDir,
|
||||||
@ -157,7 +158,7 @@ class Manager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = realpath($link);
|
$dir = $isPhar ? $link : realpath($link);
|
||||||
if ($dir !== false && is_dir($dir)) {
|
if ($dir !== false && is_dir($dir)) {
|
||||||
$this->enabledDirs[$file] = $dir;
|
$this->enabledDirs[$file] = $dir;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user