PHP code example of zanevskyas / yii2-helpers
1. Go to this page and download the library: Download zanevskyas/yii2-helpers 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/ */
zanevskyas / yii2-helpers example snippets
'controllerMap' => [
...
'rbac' => [
'class' => Kakadu\Yii2Helpers\Rbac::class,
'rbacConfig' => RbacConfig::class,
],
...
]
abstract class RbacConfig
{
/**
* @var string|Enum
*/
public static $roleClass = CustomerRole::class;
/**
* @var array
*/
public static $roleRelationships = [
CustomerRole::CUSTOMER,
CustomerRole::AUTHOR => [
CustomerRole::CUSTOMER,
],
...
];
/**
* @var array|PermissionCustomer
*/
public static $permissions = [
// Customers
PermissionCustomer::class,
PermissionSettings::class,
// Countries
...
// Cities
...
];
}
abstract class PermissionSettings
{
public const CREATE = 'CUSTOMER_SETTINGS_CREATE';
public const UPDATE = 'CUSTOMER_SETTINGS_UPDATE';
public const UPDATE_OWN = 'CUSTOMER_SETTINGS_UPDATE_OWN';
public const VIEW = 'CUSTOMER_SETTINGS_VIEW';
public const VIEW_OWN = 'CUSTOMER_SETTINGS_VIEW_OWN';
/**
* @var array
*/
public static $ruleRelationships = [
self::UPDATE_OWN => RuleOwnerCustomerSettings::class,
self::VIEW_OWN => RuleOwnerCustomerSettings::class,
];
/**
* @var array
*/
public static $permissionRelationships = [
self::UPDATE_OWN => [
self::UPDATE,
],
self::VIEW_OWN => [
self::VIEW,
],
];
/**
* @var array
*/
public static $roleRelationships = [
CustomerRole::CUSTOMER => [
self::UPDATE_OWN,
self::VIEW_OWN,
],
CustomerRole::ADMIN => [
self::CREATE,
self::UPDATE,
self::VIEW,
],
];
}
bash
php composer.phar
bash
php yii rbac/init