cli: Allow to ignore module dependencies with `module enable --force`
This commit is contained in:
parent
39e59422f4
commit
a370a99fb4
|
@ -90,17 +90,21 @@ class ModuleCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Enable a given module
|
* Enable a given module
|
||||||
*
|
*
|
||||||
* Usage: icingacli module enable <module-name>
|
* Usage: icingacli module enable <module-name> [--force]
|
||||||
*/
|
*/
|
||||||
public function enableAction()
|
public function enableAction()
|
||||||
{
|
{
|
||||||
if (! $module = $this->params->shift()) {
|
if (! $module = $this->params->shift()) {
|
||||||
$module = $this->params->shift('module');
|
$module = $this->params->shift('module');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$force = $this->params->shift('force', false);
|
||||||
|
|
||||||
if (! $module || $this->hasRemainingParams()) {
|
if (! $module || $this->hasRemainingParams()) {
|
||||||
return $this->showUsage();
|
return $this->showUsage();
|
||||||
}
|
}
|
||||||
$this->modules->enableModule($module);
|
|
||||||
|
$this->modules->enableModule($module, $force);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -237,12 +237,13 @@ class Manager
|
||||||
* Set the given module to the enabled state
|
* Set the given module to the enabled state
|
||||||
*
|
*
|
||||||
* @param string $name The module to enable
|
* @param string $name The module to enable
|
||||||
|
* @param bool $force Whether to ignore unmet dependencies
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws ConfigurationError When trying to enable a module that is not installed
|
* @throws ConfigurationError When trying to enable a module that is not installed
|
||||||
* @throws SystemPermissionException When insufficient permissions for the application exist
|
* @throws SystemPermissionException When insufficient permissions for the application exist
|
||||||
*/
|
*/
|
||||||
public function enableModule($name)
|
public function enableModule($name, $force = false)
|
||||||
{
|
{
|
||||||
if (! $this->hasInstalled($name)) {
|
if (! $this->hasInstalled($name)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
|
@ -261,10 +262,14 @@ class Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasUnmetDependencies($name)) {
|
if ($this->hasUnmetDependencies($name)) {
|
||||||
throw new ConfigurationError(
|
if ($force) {
|
||||||
t('Module "%s" can\'t be enabled. Module has unmet dependencies'),
|
Logger::warning(t('Enabling module "%s" although it has unmet dependencies'), $name);
|
||||||
$name
|
} else {
|
||||||
);
|
throw new ConfigurationError(
|
||||||
|
t('Module "%s" can\'t be enabled. Module has unmet dependencies'),
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearstatcache(true);
|
clearstatcache(true);
|
||||||
|
|
Loading…
Reference in New Issue