/**
  * Find page
  * @throws HttpException
  */
 public function beforeAction()
 {
     // request
     $request = Yii::$app->request;
     if ($slugParam = $request->get($this->slugParam, false)) {
         // controller
         $controller = Yii::$app->controller;
         // view
         $view = $controller->view;
         // cache key
         $cacheKey = 'cms_page_slug:' . $slugParam . ':' . Yii::$app->language;
         // get from cache
         if (($dataPage = Yii::$app->commonCache->get($cacheKey)) === false) {
             $cmsPage = CmsPage::find()->innerJoinWith(['cmsPageI18ns' => function ($query) use($slugParam) {
                 $query->where(['slug' => $slugParam, 'i18n_id' => Yii::$app->language]);
             }, 'cmsLayout'])->where(['activated' => 1])->asArray()->one();
             if ($cmsPage !== null && isset($cmsPage['cmsPageI18ns'][0])) {
                 $cmsPageContents = CmsPageContent::find()->innerJoinWith(['cmsPageContentI18ns' => function ($query) {
                     $query->where(['i18n_id' => Yii::$app->language]);
                 }])->where(['cms_page_id' => $cmsPage['id']])->orderBy(['index' => SORT_ASC])->asArray()->all();
                 Yii::$app->commonCache->set($cacheKey, ['cmsPage' => $cmsPage, 'cmsPageContents' => $cmsPageContents], $cmsPage['cache_duration'], new TagDependency(['tags' => [CmsPageComponent::getCacheTag(), CmsPageComponent::getCacheTag($cmsPage['id']), CmsPageComponent::getCacheTag($cmsPage['id'], $cmsPage['cmsPageI18ns'][0]['slug'], Yii::$app->language)]]));
             }
         } else {
             $cmsPage = $dataPage['cmsPage'];
             $cmsPageContents = $dataPage['cmsPageContents'];
         }
         if (!empty($cmsPage) && !empty($cmsPageContents)) {
             $view->title = $cmsPage['cmsPageI18ns'][0]['html_title'];
             if ($cmsPage['cmsPageI18ns'][0]['html_description'] != '') {
                 $view->registerMetaTag(['name' => 'description', 'content' => $cmsPage['cmsPageI18ns'][0]['html_description']]);
             }
             if ($cmsPage['cmsPageI18ns'][0]['html_keywords'] != '') {
                 $view->registerMetaTag(['name' => 'keywords', 'content' => $cmsPage['cmsPageI18ns'][0]['html_keywords']]);
             }
             $controller->layout = $cmsPage['cmsLayout']['path'];
             $this->renderView = $cmsPage['cmsLayout']['view'];
             $this->parseCmsPageContents($cmsPageContents);
             foreach ($cmsPageContents as &$cmsPageContent) {
                 if (isset($cmsPageContent['cmsPageContentI18ns'][0])) {
                     $view->blocks['cms_block_page_' . $cmsPageContent['index']] = $cmsPageContent['cmsPageContentI18ns'][0]['content'];
                 }
             }
         } else {
             throw new HttpException(404);
         }
     } else {
         throw new HttpException(404);
     }
 }