I use this, With a matchCallback I check if the actual user has view, create, update or delete rights, it’s my own implementation of an RBAC system.
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::classname(),
'only' => ['index', 'view', 'create', 'update', 'delete'],
'rules' => [
[
'actions' => ['index', 'view'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function($rule, $action){
return PermissionHelpers::userAccess('UMS', 'V');
}
],
[
'actions' => ['update'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function($rule, $action){
return PermissionHelpers::userAccess('UMS', 'U');
}
],
[
'actions' => ['create'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function($rule, $action){
return PermissionHelpers::userAccess('UMS', 'C');
}
],
[
'actions' => ['delete'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function($rule, $action){
return PermissionHelpers::userAccess('UMS', 'D');
}
],
/*
[
'actions' => ['index', 'view', 'create', 'update', 'delete'],
'allow' => true,
'roles' => ['@']
]
*/
]
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}