/** * @inheritdoc */ public function init() { parent::init(); $session = Yii::$app->session; if (WebRecord::existsMoreWebRecords()) { if (!$session->has('web')) { $session->set('web', \Yii::$app->request->get('web', \Yii::$app->params['defaultWeb'])); } if (!($this->web = WebRecord::findOne(FrontEndHelper::getWebIdFromTextId($session->get('web'))))) { $session->set('web', \Yii::$app->params['defaultWeb']); throw new NotFoundHttpException(Yii::t('front', 'The requested page does not exist.')); } } else { $this->redirect(['install/default/index']); } if (!$this->web) { $this->web = WebRecord::findOne(FrontEndHelper::getWebIdFromTextId($session->get('web'))); } $session->set('web', null); $this->setWebTheme($this->web->theme); \Yii::$app->language = \Yii::$app->request->get('language', \Yii::$app->params['defaultLanguage']); $this->language = LanguageRecord::findOne(FrontEndHelper::getLanguageIdFromAcronym()); }
/** * Finds the Language record model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return LanguageRecord the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = LanguageRecord::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException(Yii::t('back', 'The requested page does not exist.')); }