_settings_service = $settings_service; } public function actionSet($language, $section, $key, $value) { $setting = $this->findModel($section, $key); if ($setting) { $translate = $setting->findTranslation($language); if (!$translate) { $translate = new $setting->virtualClassName(); $translate->section = $section; $translate->key = $key; $translate->language = $language; } $translate->value = $value; $translate->save(); } else { $settingForm = new SettingsForm(); $settingForm->type = 'string'; $settingForm->section = $section; $settingForm->key = $key; $settingForm->active = 1; $setting = $this->_settings_service->create($settingForm); $translate = $setting->findTranslation($language); if (!$translate) { $translate = new $setting->virtualClassName(); $translate->section = $section; $translate->key = $key; $translate->language = $language; } $translate->value = $value; $translate->save(); } $this->stdout('Settings updated!' . PHP_EOL); } protected function findModel($section, $key) { if (($model = Settings::find()->andWhere(['section' => $section])->andWhere(['key' => $key])->one()) !== null) { return $model; } else { //throw new NotFoundException('The requested setting does not exist.'); return null; } } }