Свойство | Type | Description | |
---|---|---|---|
$_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. |
Méthode | Description | |
---|---|---|
__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 ) |
Méthode | Description | |
---|---|---|
_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. |
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`. |
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()`. |
Résultat | 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. |
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. |
Résultat | array | An empty array if access is allowed and an array with reasons for denial if denied. |
protected array $_autoConfig | ||
Résultat | array |
protected array $_default | ||
Résultat | array |
protected array $_rules | ||
Résultat | array |