PHP Класс CakeDC\Users\Auth\SimpleRbacAuthorize

Matches current plugin/controller/action against defined permissions in permissions.php file
Наследование: extends Cake\Auth\BaseAuthorize, use trait Cake\Log\LogTrait
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_defaultConfig
$_defaultPermissions array Default permissions to be loaded if no provided permissions

Открытые методы

Метод Описание
__construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] ) Autoload permission configuration
authorize ( array $user, Cake\Network\Request $request ) : boolean Match the current plugin/controller/action against loaded permissions Set a default role if no role is provided

Защищенные методы

Метод Описание
_checkPermissions ( array $user, string $role, Cake\Network\Request $request ) : boolean Match against permissions, return if matched Permissions are processed based on the 'permissions' config values
_loadPermissions ( string $key ) : array Load config and retrieve permissions If the configuration file does not exist, or the permissions key not present, return defaultPermissions To be mocked
_matchOrAsterisk ( string | array $possibleValues, string | mixed | null $value, boolean $allowEmpty = false ) : boolean Check if rule matched or '*' present in rule matching anything
_matchPermission ( array $permission, array $user, string $role, Cake\Network\Request $request ) : null | boolean Match the rule for current permission
_startsWith ( string $haystack, string $needle ) : boolean Checks if $heystack begins with $needle

Описание методов

__construct() публичный Метод

Autoload permission configuration
public __construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] )
$registry Cake\Controller\ComponentRegistry component registry
$config array config

_checkPermissions() защищенный Метод

Match against permissions, return if matched Permissions are processed based on the 'permissions' config values
protected _checkPermissions ( array $user, string $role, Cake\Network\Request $request ) : boolean
$user array current user array
$role string effective role for the current user
$request Cake\Network\Request request
Результат boolean true if there is a match in permissions

_loadPermissions() защищенный Метод

Load config and retrieve permissions If the configuration file does not exist, or the permissions key not present, return defaultPermissions To be mocked
protected _loadPermissions ( string $key ) : array
$key string name of the configuration file to read permissions from
Результат array permissions

_matchOrAsterisk() защищенный Метод

Check if rule matched or '*' present in rule matching anything
protected _matchOrAsterisk ( string | array $possibleValues, string | mixed | null $value, boolean $allowEmpty = false ) : boolean
$possibleValues string | array Values that are accepted (from permission config)
$value string | mixed | null Value to check with. We'll check the DASHERIZED value too
$allowEmpty boolean If true and $value is null, the rule will pass
Результат boolean

_matchPermission() защищенный Метод

Match the rule for current permission
protected _matchPermission ( array $permission, array $user, string $role, Cake\Network\Request $request ) : null | boolean
$permission array The permission configuration
$user array Current user data
$role string Effective user's role
$request Cake\Network\Request Current request
Результат null | boolean Null if permission is discarded, boolean if a final result is produced

_startsWith() защищенный Метод

Checks if $heystack begins with $needle
См. также: http://stackoverflow.com/a/7168986/2588539
protected _startsWith ( string $haystack, string $needle ) : boolean
$haystack string The whole string
$needle string The beginning to check
Результат boolean

authorize() публичный Метод

Match the current plugin/controller/action against loaded permissions Set a default role if no role is provided
public authorize ( array $user, Cake\Network\Request $request ) : boolean
$user array user data
$request Cake\Network\Request request
Результат boolean

Описание свойств

$_defaultConfig защищенное свойство

protected $_defaultConfig

$_defaultPermissions защищенное свойство

Default permissions to be loaded if no provided permissions
protected array $_defaultPermissions
Результат array