/**
  * @inheritdoc
  */
 public function init()
 {
     $cssClass = @$this->options['class'];
     parent::init();
     // significant order
     if ($cssClass != $this->options['class']) {
         \yii\helpers\Html::removeCssClass($this->options, 'nav');
     }
     $this->items = Page::find()->select(['*', 'parent_id' => '(IF(pid=1,"",pid))', 'name' => 'title'])->where(['visible' => true])->andWhere(['<>', 'pid', ''])->indexBy('id')->orderBy(['rank' => SORT_ASC])->asArray()->all();
 }
 /**
  * Renders common page view.
  * @param string $url relative url from route.
  * @return string
  * @throws \yii\web\HttpException
  */
 public function actionView($url = '/')
 {
     /**
      * @var Page $model
      */
     if (!($model = Page::childClass(true)->getCurrentPage($url))) {
         throw new \yii\web\HttpException(404, \Yii::t('modules/page', "Page not found"));
     }
     if ($model->layout) {
         $this->layout = $model->layout;
     }
     return $this->render('view', compact('model'));
 }
 /**
  * @inheritdoc
  */
 public function parseRequest($manager, $request)
 {
     if (!($result = parent::parseRequest($manager, $request))) {
         return false;
     }
     if ($this->enforceSeo) {
         Page::getCurrentPage($request->pathInfo);
         // sets seo meta tags
     }
     $manager->rules = array_filter($manager->rules, function ($rule) {
         return !$rule instanceof $this;
     });
     if (!($result2 = $manager->parseRequest($request))) {
         return $result;
     }
     return \Yii::$app->createController($result2[0]) ? $result2 : $result;
 }
 public function down()
 {
     $this->dropTable(Page::tableName());
 }