mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Remove constant ICINGAWEB_APPDIR
We should avoid use of constants.
This commit is contained in:
parent
9c103a9864
commit
bfa834fc3b
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Clicommands;
|
namespace Icinga\Clicommands;
|
||||||
|
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Cli\Command;
|
use Icinga\Cli\Command;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ class WebCommand extends Command
|
|||||||
// throw new IcingaException('Socket is required');
|
// throw new IcingaException('Socket is required');
|
||||||
}
|
}
|
||||||
if ($basedir === null) {
|
if ($basedir === null) {
|
||||||
$basedir = dirname(ICINGAWEB_APPDIR) . '/public';
|
$basedir = Icinga::app()->getBaseDir('public');
|
||||||
if (! file_exists($basedir) || ! is_dir($basedir)) {
|
if (! file_exists($basedir) || ! is_dir($basedir)) {
|
||||||
throw new IcingaException('Basedir is required');
|
throw new IcingaException('Basedir is required');
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
namespace Icinga\Form\Config\General;
|
namespace Icinga\Form\Config\General;
|
||||||
|
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Util\Translator;
|
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
|
use Icinga\Util\Translator;
|
||||||
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form class to modify the general application configuration
|
* Form class to modify the general application configuration
|
||||||
@ -71,12 +73,12 @@ class ApplicationConfigForm extends Form
|
|||||||
array(
|
array(
|
||||||
'label' => t('Module Path'),
|
'label' => t('Module Path'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()),
|
||||||
'description' => t(
|
'description' => t(
|
||||||
'Contains the directories that will be searched for available modules, separated by '
|
'Contains the directories that will be searched for available modules, separated by '
|
||||||
. 'colons. Modules that don\'t exist in these directories can still be symlinked in '
|
. 'colons. Modules that don\'t exist in these directories can still be symlinked in '
|
||||||
. 'the module folder, but won\'t show up in the list of disabled modules.'
|
. 'the module folder, but won\'t show up in the list of disabled modules.'
|
||||||
),
|
)
|
||||||
'value' => realpath(ICINGAWEB_APPDIR . '/../modules')
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -49,6 +49,13 @@ abstract class ApplicationBootstrap
|
|||||||
*/
|
*/
|
||||||
protected $baseDir;
|
protected $baseDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application directory
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $appDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icinga auto loader
|
* Icinga auto loader
|
||||||
*
|
*
|
||||||
@ -77,13 +84,6 @@ abstract class ApplicationBootstrap
|
|||||||
*/
|
*/
|
||||||
private $configDir;
|
private $configDir;
|
||||||
|
|
||||||
/**
|
|
||||||
* Application directory
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $appDir;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module manager
|
* Module manager
|
||||||
*
|
*
|
||||||
@ -117,11 +117,10 @@ abstract class ApplicationBootstrap
|
|||||||
$baseDir = dirname($this->getBootstrapDirectory());
|
$baseDir = dirname($this->getBootstrapDirectory());
|
||||||
}
|
}
|
||||||
$this->baseDir = $baseDir;
|
$this->baseDir = $baseDir;
|
||||||
|
$this->appDir = $baseDir . '/application';
|
||||||
|
|
||||||
define('ICINGAWEB_VENDORS', $baseDir . '/library/vendor');
|
define('ICINGAWEB_VENDORS', $baseDir . '/library/vendor');
|
||||||
define('ICINGAWEB_APPDIR', $baseDir . '/application');
|
|
||||||
|
|
||||||
$this->appDir = ICINGAWEB_APPDIR;
|
|
||||||
$this->libDir = realpath(__DIR__ . '/../..');
|
$this->libDir = realpath(__DIR__ . '/../..');
|
||||||
|
|
||||||
if ($configDir === null) {
|
if ($configDir === null) {
|
||||||
@ -227,21 +226,19 @@ abstract class ApplicationBootstrap
|
|||||||
*/
|
*/
|
||||||
public function getBaseDir($subDir = null)
|
public function getBaseDir($subDir = null)
|
||||||
{
|
{
|
||||||
return $this->getDirWithSubDir($subDir);
|
return $this->getDirWithSubDir($this->baseDir, $subDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for application dir
|
* Get the application directory
|
||||||
*
|
*
|
||||||
* Optional append sub directory
|
* @param string $subDir Optional sub directory to get
|
||||||
*
|
|
||||||
* @param string $subdir optional subdir
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getApplicationDir($subdir = null)
|
public function getApplicationDir($subDir = null)
|
||||||
{
|
{
|
||||||
return $this->getDirWithSubDir($this->appDir, $subdir);
|
return $this->getDirWithSubDir($this->appDir, $subDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -331,7 +328,7 @@ abstract class ApplicationBootstrap
|
|||||||
$this->moduleManager = new ModuleManager(
|
$this->moduleManager = new ModuleManager(
|
||||||
$this,
|
$this,
|
||||||
$this->configDir . '/enabledModules',
|
$this->configDir . '/enabledModules',
|
||||||
explode(':', $this->config->fromSection('global', 'modulePath', ICINGAWEB_APPDIR . '/../modules'))
|
explode(':', $this->config->fromSection('global', 'modulePath', $this->baseDir . '/modules'))
|
||||||
);
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -559,4 +559,14 @@ class Manager
|
|||||||
ksort($this->installedBaseDirs);
|
ksort($this->installedBaseDirs);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the directories where to look for installed modules
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getModuleDirs()
|
||||||
|
{
|
||||||
|
return $this->modulePaths;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class Loader
|
|||||||
public function __construct(App $app)
|
public function __construct(App $app)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->coreAppDir = ICINGAWEB_APPDIR . '/clicommands';
|
$this->coreAppDir = $app->getBaseDir('clicommands');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user