2017 © Pedro Peláez
 

yii2-extension yii2-rbac-migration

Extension for RBAC migrations for Yii2

image

rmrevin/yii2-rbac-migration

Extension for RBAC migrations for Yii2

  • Wednesday, February 25, 2015
  • by rmrevin
  • Repository
  • 0 Watchers
  • 0 Stars
  • 197 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 17 % Grown

The README.md

Yii 2 extension for RBAC migrations

Installation

Add in composer.json:, (*1)

{
    "require": {
        "rmrevin/yii2-rbac-migration": "1.1.*"
    }
}

Usage

Create new migration extends \rmrevin\yii\rbac\RbacMigration and execute as normal migration, (*2)

<?
// ...

class m140217_201400_rbac extends \rmrevin\yii\rbac\RbacMigration
{

    protected function getNewRoles()
    {
        return [
            RbacFactory::Role('admin', 'Administrator'),
            RbacFactory::Role('manager', 'Manager'),
            RbacFactory::Role('customer', 'Customer'),
            RbacFactory::Role('user', 'User'),
        ];
    }

    protected function getNewPermissions()
    {
        return [
            RbacFactory::Permission('catalog.view', 'Can view catalog'),
            RbacFactory::Permission('catalog.order', 'Can order items from catalog'),
            RbacFactory::Permission('catalog.favorite', 'Can mark favorite items'),
        ];
    }

    protected function getNewInheritance()
    {
        return [
            'admin' => [
                'manager', // inherit role manager and all permissions from role manager & user
            ],
            'manager' => [
                'user', // inherit role user and all permissions from role user
            ],
            'customer' => [
                'user', // inherit role user and all permissions from role user

                'catalog.order', // inherit permission catalog.order
                'catalog.favorite', // inherit permission catalog.favorite
            ],
            'user' => [
                'catalog.view', // inherit permission catalog.view
            ],
        ];
    }

    protected function getOldInheritance()
    {
        return [
            'admin' => [
                'manager', // inherit role manager and all permissions from role manager & user
            ],
            'manager' => [
                'user', // inherit role user and all permissions from role user
            ],
            'user' => [
            ],
        ];
    }
}

Reference

Inheritance: * protected getNewInheritance() * protected getOldInheritance(), (*3)

Rules: * protected getNewRules() * protected getRenamedRules() * protected getRemoveRules(), (*4)

Roles: * protected getNewRoles() * protected getRenamedRoles() * protected getRemoveRoles(), (*5)

Permissions: * protected getNewPermissions() * protected getRenamedPermissions() * protected getRemovePermissions(), (*6)

The Versions

25/02 2015

dev-master

9999999-dev

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

25/02 2015

2.0.2

2.0.2.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

25/02 2015

2.0.1

2.0.1.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

25/02 2015

2.0.0

2.0.0.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

27/01 2015

1.1.1

1.1.1.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

27/01 2015

1.1.0

1.1.0.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

27/01 2015

1.0.2

1.0.2.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

13/01 2015

1.0.1

1.0.1.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac

13/01 2015

1.0.0

1.0.0.0

Extension for RBAC migrations for Yii2

  Sources   Download

MIT

The Requires

 

migration yii rbac