pages = $pages; } public function behaviors(): array { return [ 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => ['view'], 'allow' => true, 'roles' => ['Pages'], ], [ // all the action are accessible to admin 'allow' => true, 'roles' => ['admin'], ], ], ], ]; } /** * @param $id * @return mixed * @throws NotFoundHttpException * @internal param string $slug */ public function actionView($id) { if (!$page = $this->pages->find($id)) { throw new NotFoundHttpException('The requested page does not exist.'); } return $this->render('view', [ 'page' => $page, ]); } }