Closed jsobers1331 closed 8 years ago
Can you explain to me how i can import your permissions rules using https://github.com/dektrium/yii2-rbac ?
I don't have the faintest idea where to start.
<?php use \rmrevin\yii\module\Comments\Permission; use \rmrevin\yii\module\Comments\rbac\ItsMyComment; $AuthManager = \Yii::$app->getAuthManager(); $ItsMyCommentRule = new ItsMyComment(); $AuthManager->add($ItsMyCommentRule); $AuthManager->add(new \yii\rbac\Permission([ 'name' => Permission::CREATE, 'description' => 'Can create own comments', ])); $AuthManager->add(new \yii\rbac\Permission([ 'name' => Permission::UPDATE, 'description' => 'Can update all comments', ])); $AuthManager->add(new \yii\rbac\Permission([ 'name' => Permission::UPDATE_OWN, 'ruleName' => $ItsMyCommentRule->name, 'description' => 'Can update own comments', ])); $AuthManager->add(new \yii\rbac\Permission([ 'name' => Permission::DELETE, 'description' => 'Can delete all comments', ])); $AuthManager->add(new \yii\rbac\Permission([ 'name' => Permission::DELETE_OWN, 'ruleName' => $ItsMyCommentRule->name, 'description' => 'Can delete own comments', ]));
I have not worked with this extension, but as I understand it involves a manual control of the rules. You can wrap the creation of these roles in the migration or add them manually via the interface.
Can you explain to me how i can import your permissions rules using https://github.com/dektrium/yii2-rbac ?
I don't have the faintest idea where to start.