[ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => ['error'], 'allow' => true, ], [ 'actions' => ['index'], 'allow' => true, 'roles' => ['Dashboard'], ], [ // all the action are accessible to admin 'allow' => true, 'roles' => ['admin'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } /** * @inheritdoc */ public function actions() { return [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], ]; } /** * Displays homepage. * * @return string */ public function actionIndex() { return $this->render('index'); } public function beforeAction($action) { if ($action->id === 'error') { $this->layout = 'error'; } return parent::beforeAction($action); } }