Class RuleInvoker
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.
Property Summary
Method Summary
- 
          __construct() publicConstructor 
- 
          __invoke() publicInvoke the rule. 
- 
          setName() publicSet the rule name. 
- 
          setOptions() publicSet options for the rule invocation. 
Method Detail
__construct() ¶ public
__construct(callable $rule, ?string $name, array $options = [])Constructor
Options
- errorFieldThe field errors should be set onto.
- messageThe 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 optional
- The options for the rule. See above. 
__invoke() ¶ public
__invoke(Cake\Datasource\EntityInterface $entity, array $scope): boolInvoke the rule.
Parameters
- 
                Cake\Datasource\EntityInterface$entity
- The entity the rule should apply to. 
- 
                array$scope
- The rule's scope/options. 
Returns
boolWhether or not the rule passed.
setName() ¶ public
setName(string|null $name): $thisSet the rule name.
Only truthy names will be set.
Parameters
- 
                string|null$name
- The name to set. 
Returns
$thissetOptions() ¶ public
setOptions(array $options): $thisSet options for the rule invocation.
Old options will be merged with the new ones.
Parameters
- 
                array$options
- The options to set. 
Returns
$this