* @copyright (c), Thread */ class PageController extends BaseController { public $title = "Page"; public $layout = "@app/layouts/base"; public $defaultAction = 'index'; /** * */ public function init() { parent::init(); $this->breadcrumbs = [ [ 'label' => Yii::t('page', 'Pages') ] ]; } /** * @return array */ public function behaviors() { return [ 'verbs' => [ 'class' => VerbFilter::class, 'actions' => [ 'index' => ['get'], 'contacts' => ['get'], 'view' => ['get'], ], ] ]; } /** * @return array */ public function actions() { $page = Page::findByAlias(Yii::$app->request->get('alias', ''))->asArray()->one(); if(($page) && $page['id'] == Page::RESULT_PAGE_ID && Yii::$app->getUser()->isGuest){ throw new NotFoundHttpException(); } return [ 'view' => [ 'class' => RecordView::class, 'modelClass' => Page::class, 'methodName' => 'getByAlias', 'layout' => '@app/layouts/base' ] ]; } /** * * @return string */ public function actionIndex() { $this->layout = "/start"; return $this->run('view', ['alias' => 'start']); } }