PHP code example of rmrevin / yii2-rbac-command

1. Go to this page and download the library: Download rmrevin/yii2-rbac-command 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-command example snippets




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()
    {
        // ...
    }
}

<?
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,
		],
	],
	// ...
];