Fr3nch13/CakePHP Utilities

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.

Table of Contents

Properties

$_rulesChecker  : RulesChecker
The domain rules to be applied to entities saved by this table

Methods

buildRules()  : RulesChecker
Returns a RulesChecker object after modifying the one that was supplied.
checkRules()  : bool
Returns whether the passed entity complies with all the rules stored in the rules checker.
rulesChecker()  : RulesChecker
Returns the RulesChecker for this instance.

Properties

Methods

buildRules()

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

public buildRules(RulesChecker $rules) : RulesChecker

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

Parameters
$rules : RulesChecker

The rules object to be modified.

Return values
RulesChecker

checkRules()

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

public checkRules(EntityInterface $entity[, string $operation = RulesChecker::CREATE ][, ArrayObject|array<string|int, mixed>|null $options = null ]) : bool
Parameters
$entity : EntityInterface

The entity to check for validity.

$operation : string = RulesChecker::CREATE

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

$options : ArrayObject|array<string|int, mixed>|null = null

The options To be passed to the rules.

Return values
bool

rulesChecker()

Returns the RulesChecker for this instance.

public rulesChecker() : RulesChecker

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.

Tags
see
RulesChecker
Return values
RulesChecker

        
On this page

Search results