コード例 #1
0
 public function getSource($name)
 {
     $currentLanguage = \Yii::$app->language;
     $defaultLanguage = ArrayHelper::getValue(EmailManager::getInstance()->languages, 0, 'en-US');
     /** @var Template $model */
     $model = Template::find()->where(['shortcut' => $name])->andWhere('language = :currentLanguage OR language = :defaultLanguage OR language = :systemDefaultLanguage', [':currentLanguage' => $currentLanguage, ':defaultLanguage' => $defaultLanguage, ':systemDefaultLanguage' => 'en-US'])->one();
     if (!$model) {
         \Yii::error("Missing template {$name}, current language {$currentLanguage}, default language {$defaultLanguage}", 'email');
         return "!!! UNKNOWN TEMPLATE {$name} !!!";
     }
     return $model->getAttribute($this->attributeName);
 }
コード例 #2
0
 /**
  * Finds the Template model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Template the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Template::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }