1. Go to this page and download the library: Download romi45/yii2-rbac-collector 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/ */
romi45 / yii2-rbac-collector example snippets
'modules' => [
...
'rbacc' => [
'class' => 'rbacc\Module',
'collection' => [
// Here is a list of your RBAC config classes. Example you can get in /example directory
'app\modules\user\rbac\Config',
'app\modules\blog\rbac\Config',
'app\modules\hobby\rbac\YouCanNameItAsYouWant',
]
],
...
]
namespace rbacc\example;
use rbacc\components\ConfigBase;
use rbacc\example\rules\UpdateOwnDataRule;
use yii\rbac\Item;
/**
* Class Config
*
* Example RBAC configuration class
*
* @package user\rbac
*/
class Config extends ConfigBase
{
/**
* Gets config data as array
*
* @return array
*/
public function getData()
{
return [
'user___user__view_profile' => 'View user profile',
'user___user__view_own_profile' => [
'type' => Item::TYPE_PERMISSION,
'description' => 'View user own profile',
'rule' => new UpdateOwnDataRule(),
'children' => ['user___user__view_profile']
],
'user' => [
'type' => Item::TYPE_ROLE,
'description' => 'User',
'children' => ['user___user__view_own_profile'],
],
'admin' => [
'type' => Item::TYPE_ROLE,
'description' => 'Admin',
'children' => ['user___user__view_profile']
],
'owner' => [
'type' => Item::TYPE_ROLE,
'description' => 'Application owner',
'children' => ['admin'],
]
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.