diff --git a/application/clicommands/ModuleCommand.php b/application/clicommands/ModuleCommand.php index cd3390404..41bc7c377 100644 --- a/application/clicommands/ModuleCommand.php +++ b/application/clicommands/ModuleCommand.php @@ -90,17 +90,21 @@ class ModuleCommand extends Command /** * Enable a given module * - * Usage: icingacli module enable + * Usage: icingacli module enable [--force] */ public function enableAction() { if (! $module = $this->params->shift()) { $module = $this->params->shift('module'); } + + $force = $this->params->shift('force', false); + if (! $module || $this->hasRemainingParams()) { return $this->showUsage(); } - $this->modules->enableModule($module); + + $this->modules->enableModule($module, $force); } /** diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index abb923302..d50b3244d 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -237,12 +237,13 @@ class Manager * Set the given module to the enabled state * * @param string $name The module to enable + * @param bool $force Whether to ignore unmet dependencies * * @return $this * @throws ConfigurationError When trying to enable a module that is not installed * @throws SystemPermissionException When insufficient permissions for the application exist */ - public function enableModule($name) + public function enableModule($name, $force = false) { if (! $this->hasInstalled($name)) { throw new ConfigurationError( @@ -261,10 +262,14 @@ class Manager } if ($this->hasUnmetDependencies($name)) { - throw new ConfigurationError( - t('Module "%s" can\'t be enabled. Module has unmet dependencies'), - $name - ); + if ($force) { + Logger::warning(t('Enabling module "%s" although it has unmet dependencies'), $name); + } else { + throw new ConfigurationError( + t('Module "%s" can\'t be enabled. Module has unmet dependencies'), + $name + ); + } } clearstatcache(true);