mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
Merge pull request #3852 from Icinga/feature/cli-load-enabled-modules
CLI: Automatically load enabled modules if not disabled
This commit is contained in:
commit
5145de6b50
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
namespace Icinga\Cli;
|
namespace Icinga\Cli;
|
||||||
|
|
||||||
use Icinga\Cli\Screen;
|
|
||||||
use Icinga\Util\Translator;
|
|
||||||
use Icinga\Cli\Params;
|
|
||||||
use Icinga\Application\Config;
|
|
||||||
use Icinga\Application\ApplicationBootstrap as App;
|
use Icinga\Application\ApplicationBootstrap as App;
|
||||||
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
use Icinga\Exception\NotReadableError;
|
||||||
|
use Icinga\Util\Translator;
|
||||||
|
|
||||||
abstract class Command
|
abstract class Command
|
||||||
{
|
{
|
||||||
@ -45,6 +45,9 @@ abstract class Command
|
|||||||
|
|
||||||
protected $defaultActionName = 'default';
|
protected $defaultActionName = 'default';
|
||||||
|
|
||||||
|
/** @var bool Whether to automatically load enabled modules */
|
||||||
|
protected $loadEnabledModules = true;
|
||||||
|
|
||||||
public function __construct(App $app, $moduleName, $commandName, $actionName, $initialize = true)
|
public function __construct(App $app, $moduleName, $commandName, $actionName, $initialize = true)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
@ -57,6 +60,15 @@ abstract class Command
|
|||||||
$this->isVerbose = $this->params->shift('verbose', false);
|
$this->isVerbose = $this->params->shift('verbose', false);
|
||||||
$this->isDebugging = $this->params->shift('debug', false);
|
$this->isDebugging = $this->params->shift('debug', false);
|
||||||
$this->configs = [];
|
$this->configs = [];
|
||||||
|
|
||||||
|
if ($this->loadEnabledModules) {
|
||||||
|
try {
|
||||||
|
$app->getModuleManager()->loadEnabledModules();
|
||||||
|
} catch (NotReadableError $e) {
|
||||||
|
Logger::error(new IcingaException('Cannot load enabled modules. An exception was thrown:', $e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($initialize) {
|
if ($initialize) {
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user