\Cake\DatasourceRuleInvoker

Contains logic for invoking an application rule.

Combined with Cake\Datasource\RuleChecker as an implementation detail to de-duplicate rule decoration and provide cleaner separation of duties.

Summary

Methods
Properties
Constants
__construct()
setOptions()
setName()
__invoke()
No public properties found
No constants found
No protected methods found
$name
$options
$rule
N/A
No private methods found
No private properties found
N/A

Properties

$name

$name : string

The rule name

Type

string

$options

$options : array

Rule options

Type

array

$rule

$rule : callable

Rule callable

Type

callable

Methods

__construct()

__construct(callable  $rule, string  $name, array  $options = array()) 

Constructor

Options

  • errorField The field errors should be set onto.
  • message The error message.

Individual rules may have additional options that can be set here. Any options will be passed into the rule as part of the rule $scope.

Parameters

callable $rule

The rule to be invoked.

string $name

The name of the rule. Used in error messsages.

array $options

The options for the rule. See above.

setOptions()

setOptions(array  $options) : $this

Set options for the rule invocation.

Old options will be merged with the new ones.

Parameters

array $options

The options to set.

Returns

$this

setName()

setName(string  $name) : $this

Set the rule name.

Only truthy names will be set.

Parameters

string $name

The name to set.

Returns

$this

__invoke()

__invoke(\Cake\Datasource\EntityInterface  $entity, array  $scope) : boolean

Invoke the rule.

Parameters

\Cake\Datasource\EntityInterface $entity

The entity the rule should apply to.

array $scope

The rule's scope/options.

Returns

boolean —

Whether or not the rule passed.