public function parseRequest($manager, $request) { $result = parent::parseRequest($manager, $request); if (isset($result[1]) && $result[1]['route']) { $route = $result[1]['route']; $page = Page::getDb()->cache(function () use($route) { return Page::find()->where(['route' => $route])->one(); }); if ($page) { return [$this->route, ['route' => $route]]; } } return false; }
public function run() { if (($route = Yii::$app->request->getQueryParam('route')) == null) { throw new NotFoundHttpException(Yii::t('cms', 'Page not found.')); } $page = Page::getDb()->cache(function () use($route) { return Page::find()->byRoute($route)->one(); }, null, new TagDependency(['tags' => 'cms.page.' . $route])); if (!isset($page)) { throw new NotFoundHttpException(Yii::t('cms', 'Page not found.')); } if ($page->layout) { $this->controller->layout = $page->layout; } if ($page->type == Page::TYPE_CONTENT) { $this->view = 'content-view'; } $result = $this->controller->render($this->view, ['page' => $page]); //@TODO add tag dependency by blocks return $result; }