rmrevin/yii2-rbac-command Extension for RBAC rules update for Yii2

rbaccommand

Yii 2 RBAC update command

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

Changelog

2017-03-05 - 1.6.1

  • Fix Db component inside DbManager.
  • Update readme.

2017-03-05 - 1.6.0

  • Improve support DI container.

2016-06-08 - 1.5.0

  • Improve support DI container.
  • Refactoring.

2015-12-23 - 1.4.0

  • Private methods are now protected.
  • Methods Command::rules() and Command::permissions() are now abstract.
  • Improve phpdoc.
  • Refactoring.

2015-06-19 - 1.3.1

  • Added auto invalidate cache if use yii\rbac\DbManager.

2015-06-19 - 1.3.0

  • Added feature to cache assignment in case of unavailability of usage transactions.
  • Refactoring.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.6.1 is the latest of 13 releases



MIT license
Stats
7 github stars & 1 github forks
12 downloads in the last day
257 downloads in the last 30 days
11103 total downloads