PHP 클래스 li3_access\extensions\adapter\security\access\Rules

상속: extends lithium\core\Object
파일 보기 프로젝트 열기: tmaiaroto/li3_access 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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