Пример #1
0
 /**
  * Init module
  */
 public function init()
 {
     parent::init();
     $this->config = Config::getConfig('\\maddoger\\website\\frontend\\Module', is_array($this->config) ? $this->config : []);
     if (!isset(Yii::$app->i18n->translations['maddoger/website'])) {
         Yii::$app->i18n->translations['maddoger/website'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@maddoger/website/common/messages', 'sourceLanguage' => 'en-US'];
     }
 }
Пример #2
0
 public function actionIndex()
 {
     $model = Config::getConfig(Module::className());
     if ($model->load(Yii::$app->request->post())) {
         //$validate = $model->validate();
         foreach (I18N::getAvailableLanguages() as $language) {
             $modelI18n = $model->getTranslation($language['locale']);
             $modelI18n->load(Yii::$app->request->post());
         }
         if ($model->save()) {
             Yii::$app->session->addFlash('success', Yii::t('maddoger/website', 'Saved.'));
             return $this->refresh();
         }
     }
     return $this->render('index', ['model' => $model]);
 }