cache->get([__CLASS__, $this->model->block_id]); if (!$this->model->cache || $html === false) { $template = $this->model->template; $articles = Article::find()->published() ->andFilterWhere(['module' => $template['module']]) ->andFilterWhere(['category_id' => $template['category']]) ->orderBy([$template['order'] => SORT_DESC]) ->limit($template['limit']) ->all(); $items = []; foreach ($articles as $article) { $items[] = Html::a($article->title, ['/article/view', 'id' => $article->id]); } $html = Html::ul($items, ['class' => 'post-list', 'encode' => false]); \Yii::$app->cache->set([__CLASS__, $this->model->block_id], $html); } return $html; } }