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;
|
||||
|
||||
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\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
use Icinga\Util\Translator;
|
||||
|
||||
abstract class Command
|
||||
{
|
||||
|
@ -45,6 +45,9 @@ abstract class Command
|
|||
|
||||
protected $defaultActionName = 'default';
|
||||
|
||||
/** @var bool Whether to automatically load enabled modules */
|
||||
protected $loadEnabledModules = true;
|
||||
|
||||
public function __construct(App $app, $moduleName, $commandName, $actionName, $initialize = true)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
@ -57,6 +60,15 @@ abstract class Command
|
|||
$this->isVerbose = $this->params->shift('verbose', false);
|
||||
$this->isDebugging = $this->params->shift('debug', false);
|
||||
$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) {
|
||||
$this->init();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue