\Cake\DatasourceRulesAwareTrait

A trait that allows a class to build and apply application.

rules.

If the implementing class also implements EventAwareTrait, then events will be emitted when rules are checked.

The implementing class is expected to define the RULES_CLASS constant if they need to customize which class is used for rules objects.

Summary

Methods
Properties
Constants
checkRules()
rulesChecker()
buildRules()
No public properties found
No constants found
No protected methods found
$_rulesChecker
N/A
No private methods found
No private properties found
N/A

Properties

$_rulesChecker

$_rulesChecker : \Cake\Datasource\RulesChecker

The domain rules to be applied to entities saved by this table

Type

\Cake\Datasource\RulesChecker

Methods

checkRules()

checkRules(\Cake\Datasource\EntityInterface  $entity, string  $operation = \Cake\Datasource\RulesChecker::CREATE, \ArrayObject|array|null  $options = null) : boolean

Returns whether or not the passed entity complies with all the rules stored in the rules checker.

Parameters

\Cake\Datasource\EntityInterface $entity

The entity to check for validity.

string $operation

The operation being run. Either 'create', 'update' or 'delete'.

\ArrayObject|array|null $options

The options To be passed to the rules.

Returns

boolean

rulesChecker()

rulesChecker() : \Cake\Datasource\RulesChecker

Returns the RulesChecker for this instance.

A RulesChecker object is used to test an entity for validity on rules that may involve complex logic or data that needs to be fetched from relevant datasources.

Returns

\Cake\Datasource\RulesChecker

buildRules()

buildRules(\Cake\Datasource\RulesChecker  $rules) : \Cake\Datasource\RulesChecker

Returns a RulesChecker object after modifying the one that was supplied.

Subclasses should override this method in order to initialize the rules to be applied to entities saved by this instance.

Parameters

\Cake\Datasource\RulesChecker $rules

The rules object to be modified.

Returns

\Cake\Datasource\RulesChecker