yii2 - How to add use RBAC rule to control access to controller action? -


i setting new yii 2.0 project, , trying use rbac control access controller actions. using dbmanager. how set rules array @ top of controller class control access actions?

tipically in controller yon can add rule in way

public function behaviors() {     return [         'access' => [             'class' => accesscontrol::classname(),             'rules' => [                 [                     'actions' => ['index','view'],                     'allow' => true,                     'roles' => ['viewer', 'viewermodel1', 'viewermodel2'],                 ],                 [                     'allow' => true,                     'roles' => ['superadmin', 'admin', 'manage', 'managermodel1', 'managermodel2'],                 ],                ],         ],                 'verbs' => [             'class' => verbfilter::classname(),             'actions' => [                 'delete' => ['post'],             ],         ],     ]; } 

this rule permit access index , view 'viewer', 'viewermodel1', 'viewermodel2' . access management 'superadmin', 'admin', 'manage', 'managermodel1', 'managermodel2' in way other role cna't access views application controller


Comments