mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Fix: Settings cli rewrite dynamic config when required
This commit is contained in:
parent
346c29fdf2
commit
c4934ea5e1
@ -10,6 +10,7 @@ namespace humhub\commands;
|
|||||||
|
|
||||||
use humhub\components\Module;
|
use humhub\components\Module;
|
||||||
use humhub\components\SettingsManager;
|
use humhub\components\SettingsManager;
|
||||||
|
use humhub\libs\DynamicConfig;
|
||||||
use humhub\models\Setting;
|
use humhub\models\Setting;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
@ -88,6 +89,8 @@ class SettingsController extends Controller
|
|||||||
$settingsManager = new SettingsManager(['moduleId' => $moduleId]);
|
$settingsManager = new SettingsManager(['moduleId' => $moduleId]);
|
||||||
$settingsManager->set($name, $value);
|
$settingsManager->set($name, $value);
|
||||||
|
|
||||||
|
$this->handleDynamicConfig($moduleId, $name);
|
||||||
|
|
||||||
$this->stdout("\n*** Successfully set setting\n\n", Console::FG_GREEN);
|
$this->stdout("\n*** Successfully set setting\n\n", Console::FG_GREEN);
|
||||||
$this->stdout("Name:\t\t" . $name . "\n");
|
$this->stdout("Name:\t\t" . $name . "\n");
|
||||||
$this->stdout("Module ID:\t" . $moduleId . "\n\n");
|
$this->stdout("Module ID:\t" . $moduleId . "\n\n");
|
||||||
@ -110,6 +113,7 @@ class SettingsController extends Controller
|
|||||||
|
|
||||||
$settingsManager = new SettingsManager(['moduleId' => $moduleId]);
|
$settingsManager = new SettingsManager(['moduleId' => $moduleId]);
|
||||||
$settingsManager->delete($name);
|
$settingsManager->delete($name);
|
||||||
|
$this->handleDynamicConfig($moduleId, $name);
|
||||||
|
|
||||||
$this->stdout("\n*** Successfully deleted setting\n\n", Console::FG_GREEN);
|
$this->stdout("\n*** Successfully deleted setting\n\n", Console::FG_GREEN);
|
||||||
$this->stdout("Name:\t\t" . $name . "\n");
|
$this->stdout("Name:\t\t" . $name . "\n");
|
||||||
@ -118,5 +122,20 @@ class SettingsController extends Controller
|
|||||||
return ExitCode::OK;
|
return ExitCode::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles dynamic config rewrite if required
|
||||||
|
*
|
||||||
|
* @param $moduleId
|
||||||
|
* @param $name
|
||||||
|
*/
|
||||||
|
private function handleDynamicConfig($moduleId, $name)
|
||||||
|
{
|
||||||
|
if (DynamicConfig::needRewrite($moduleId, $name)) {
|
||||||
|
// Force reload
|
||||||
|
Yii::$app->settings->init();
|
||||||
|
DynamicConfig::rewrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +180,21 @@ class DynamicConfig extends BaseObject
|
|||||||
self::save($config);
|
self::save($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the config should be rewritten based on changed setting name
|
||||||
|
*
|
||||||
|
* @param $moduleId
|
||||||
|
* @param $name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function needRewrite($moduleId, $name)
|
||||||
|
{
|
||||||
|
return (in_array($name, [
|
||||||
|
'name', 'defaultLanguage', 'timeZone', 'cache.class', 'mailer.transportType',
|
||||||
|
'mailer.hostname', 'mailer.username', 'mailer.password', 'mailer.encryption',
|
||||||
|
'mailer.port', 'horImageScrollOnMobile']));
|
||||||
|
}
|
||||||
|
|
||||||
public static function getConfigFilePath()
|
public static function getConfigFilePath()
|
||||||
{
|
{
|
||||||
return Yii::getAlias(Yii::$app->params['dynamicConfigFile']);
|
return Yii::getAlias(Yii::$app->params['dynamicConfigFile']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user