Enh: Allow enable/disable modules by CLI

This commit is contained in:
Lucas Bartholemy 2018-06-14 11:14:30 +02:00
parent 5881a4682c
commit b26d41e072
2 changed files with 50 additions and 1 deletions

View File

@ -11,6 +11,7 @@ HumHub Change Log
- Fix: Improved ZendLucence driver error handling
- Fix #3148: Upload space picture dose not use file size setting in HumHub (acs-ferreira)
- Fix: Incorrect last visit date shown in space admin pending members view (acs-ferreira)
- Enh: Allow enable/disable modules by CLI
1.2.7 (May 23, 2018)

View File

@ -8,8 +8,10 @@
namespace humhub\modules\admin\commands;
use Yii;
use humhub\components\Module;
use humhub\modules\admin\libs\OnlineModuleManager;
use Yii;
use yii\helpers\Console;
/**
* HumHub Module Managament
@ -170,4 +172,50 @@ class ModuleController extends \yii\console\Controller
}
}
/**
* Enables an installed module
*
* @param string $moduleId the module id
* @return int the exit code
*/
public function actionEnable($moduleId)
{
$this->stdout(Yii::t('AdminModule.console', "--- Enable module: {moduleId} ---\n\n", ['moduleId' => $moduleId]), Console::BOLD);
/** @var Module $module */
$module = Yii::$app->moduleManager->getModule($moduleId);
if ($module === null) {
$this->stdout(Yii::t('AdminModule.console', "Module not found!\n"), Console::FG_RED, Console::BOLD);
return 1;
}
$module->enable();
$this->stdout(Yii::t('AdminModule.console', "\nModule successfully enabled!\n"), Console::FG_GREEN, Console::BOLD);
return 0;
}
/**
* Disables an enabled module
*
* @param string $moduleId the module id
* @return int the exit code
*/
public function actionDisable($moduleId)
{
$this->stdout(Yii::t('AdminModule.console', "--- Disable module: {moduleId} ---\n\n", ['moduleId' => $moduleId]), Console::BOLD);
/** @var Module $module */
$module = Yii::$app->moduleManager->getModule($moduleId);
if ($module === null || !Yii::$app->hasModule($moduleId)) {
$this->stdout(Yii::t('AdminModule.console', "Module not found or activated!\n"), Console::FG_RED, Console::BOLD);
return 1;
}
$module->disable();
$this->stdout(Yii::t('AdminModule.console', "\nModule successfully disabled!\n"), Console::FG_GREEN, Console::BOLD);
return 0;
}
}