Exemple #1
0
 /**
  * Loads the messages from database.
  * You may override this method to customize the message storage in the database.
  * @param string $category the message category.
  * @param string $language the target language.
  * @return array the messages loaded from database.
  */
 protected function loadMessagesFromDb($category, $language)
 {
     $messages = i18nModel::findAll(['category' => $category, 'locale' => $language]);
     return ArrayHelper::map($messages, 'source', 'message');
 }
Exemple #2
0
 /**
  * Finds the I18n model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return I18n the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = I18n::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }