Trait RulesAwareTrait

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.

Namespace: Cake\Datasource

Properties summary

  • $_rulesChecker protected
    \Cake\Datasource\RulesChecker

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

Method Summary

  • buildRules() public

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

  • checkRules() public

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

  • rulesChecker() public

    Returns the RulesChecker for this instance.

Method Detail

buildRules() public

buildRules(\Cake\Datasource\RulesChecker $rules)

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

checkRules() public

checkRules(\Cake\Datasource\EntityInterface $entity, string $operation, mixed $options)

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 optional

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

\ArrayObject|array|null $options optional

The options To be passed to the rules.

Returns

bool

rulesChecker() public

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

See Also

\Cake\Datasource\RulesChecker

Property Detail

$_rulesChecker protected

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

Type

\Cake\Datasource\RulesChecker

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/trait-Cake.Datasource.RulesAwareTrait.html