Пример #1
0
 public function init()
 {
     parent::init();
     $this->_texts = Data::cache(TextModel::CACHE_KEY, 3600, function () {
         $models = TextModel::find()->where(['status' => TextModel::STATUS_PUBLISHED])->all();
         $return = [];
         foreach ($models as $k => $model) {
             $return[$model->slug . '_' . \Yii::$app->language][$model->id] = $model;
         }
         return $return;
     });
 }
Пример #2
0
 /**
  * @return Country[]
  */
 public function api_countries()
 {
     return Data::cache($this->makeCacheKey(), function () {
         return Country::find()->all();
     });
 }