rmrevin / yii2-rbac-command
Extension for RBAC rules update for Yii2
Installs: 16 994
Dependents: 3
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: 2.0.*
README
This extension provides a console command to update the RBAC rules, roles and permissions for Yii framework 2.0 applications.
Installation
composer require "rmrevin/yii2-rbac-command:~1.6"
Configuration
Create new console command extends \rmrevin\yii\rbac\Command
(example)
<?php namespace app\commands; class RbacCommand extends \rmrevin\yii\rbac\Command { protected function rules() { // ... } protected function roles() { // ... } protected function permissions() { // ... } protected function inheritanceRoles() { // ... } protected function inheritancePermissions() { // ... } }
In console application config
(example: /protected/config/console.php
)
<? return [ // ... 'controllerMap' => [ // ... 'rbac' => [ 'class' => 'app\commands\RbacCommand', 'batchSize' => 1000, 'forceAssign' => ['user'], // force assign user role for all users 'assignmentsMap' => [ 'frontend.old' => 'frontend.new', // after next update all `frontend.old` will be replaced by `frontend.new` ], 'useTransaction' => true, 'useCache' => true, ], ], // ... ];
Usage
Execute command in command line
yii rbac/update