1. Go to this page and download the library: Download rmrevin/yii2-rbac-migration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rmrevin / yii2-rbac-migration example snippets
<?
// ...
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' => [
],
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.