PHP Класс li3_access\extensions\adapter\security\access\Rules

Наследование: extends lithium\core\Object
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_autoConfig array Configuration that will be automatically assigned to class properties.
$_default array Lists a subset of rules defined in $_rules which should be checked by default on every call to check() (unless overridden by passed options).
$_rules array Rules are named closures that must either return true or false.

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

Метод Описание
__construct ( array $config = [] ) Sets default adapter configuration.
add ( string $name, function $rule = null ) Adds an Access rule. This works much like the Validator class.
check ( mixed $user, mixed $params, array $options = [] ) : array The Rules adapter will use check to test the provided data against a number of given rules. Extra data that may be required to make an informed decision about access can be passed in the $options array. This extra data will vary from app to app and rules will need to be added to handle it. The default rules assume some general cases and more can be added or passed directly to this method.
get ( string $name = null ) : mixed Simply returns the rules that are currently available. Optionally, passing a name will return just that rule or false if it doesn't exist.
getRules ( string $name = null )

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

Метод Описание
_call ( array $rule, mixed $user, mixed $request, array $options ) : boolean Extracts a callable rule either from a rule definition assigned as a closure, or a string reference to a rule defined in a key in the $_rules array.
_init ( ) : void Initializes default rules to use.

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

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

Sets default adapter configuration.
public __construct ( array $config = [] )
$config array Adapter configuration, which includes the following default options: - `'rules'` _array_: An array of rules to be added to the default rules initialized by the adapter. See the `'rules'` option of the `check()` method for more information on the acceptable format of these values. - `'default'` _array_: The default list of rules to use when performing access checks. - `'allowAny'` _boolean_: If set to `true`, access checks will return successful if _any_ access rule passes. Otherwise, all are required to pass in order for the check to succeed. Defaults to `false`.

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

Extracts a callable rule either from a rule definition assigned as a closure, or a string reference to a rule defined in a key in the $_rules array.
protected _call ( array $rule, mixed $user, mixed $request, array $options ) : boolean
$rule array The rule definition array.
$user mixed The value representing the user making the request. Usually an array.
$request mixed The value representing request data or the object being access.
$options array Any options passed to `check()`.
Результат boolean Returns `true` if the call to the rule was successful, otherwise `false` if the call failed, or if a callable rule was not found.

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

Initializes default rules to use.
protected _init ( ) : void
Результат void

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

All rules should be anonymous functions and will be passed $user, $request, and $options which will contain the entire rule array which contains its own name plus other data that could be used to determine access.
public add ( string $name, function $rule = null )
$name string The rule name.
$rule function The closure for the rule, which has to return true or false.

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

The Rules adapter will use check to test the provided data against a number of given rules. Extra data that may be required to make an informed decision about access can be passed in the $options array. This extra data will vary from app to app and rules will need to be added to handle it. The default rules assume some general cases and more can be added or passed directly to this method.
public check ( mixed $user, mixed $params, array $options = [] ) : array
$user mixed The user data array that holds all necessary information about the user requesting access. Or false (because `Auth::check()` can return `false`).
$params mixed The Lithium `Request` object, or an array with at least 'request', and 'params'
$options array An array of additional options.
Результат array An empty array if access is allowed and an array with reasons for denial if denied.

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

Simply returns the rules that are currently available. Optionally, passing a name will return just that rule or false if it doesn't exist.
public get ( string $name = null ) : mixed
$name string The rule name (optional).
Результат mixed Either an array of rule closures, a single rule closure, or `false`.

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

Устаревший:
public getRules ( string $name = null )
$name string The rule name (optional).

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

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

Configuration that will be automatically assigned to class properties.
protected array $_autoConfig
Результат array

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

Lists a subset of rules defined in $_rules which should be checked by default on every call to check() (unless overridden by passed options).
protected array $_default
Результат array

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

Rules are named closures that must either return true or false.
protected array $_rules
Результат array