/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Datasource
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Datasource/RulesAwareTrait.php (4092B)
rulesChecker();
$options = $options ?: new ArrayObject();
$options = is_array($options) ? new ArrayObject($options) : $options;
$hasEvents = ($this instanceof EventDispatcherInterface);
if ($hasEvents) {
$event = $this->dispatchEvent(
'Model.beforeRules',
compact('entity', 'options', 'operation')
);
if ($event->isStopped()) {
return $event->getResult();
}
}
$result = $rules->check($entity, $operation, $options->getArrayCopy());
if ($hasEvents) {
$event = $this->dispatchEvent(
'Model.afterRules',
compact('entity', 'options', 'result', 'operation')
);
if ($event->isStopped()) {
return $event->getResult();
}
}
return $result;
}
/**
* 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.
*
* @see \Cake\Datasource\RulesChecker
* @return \Cake\Datasource\RulesChecker
*/
public function rulesChecker(): RulesChecker
{
if ($this->_rulesChecker !== null) {
return $this->_rulesChecker;
}
/** @psalm-var class-string<\Cake\Datasource\RulesChecker> $class */
$class = defined('static::RULES_CLASS') ? static::RULES_CLASS : RulesChecker::class;
$this->_rulesChecker = $this->buildRules(new $class(['repository' => $this]));
$this->dispatchEvent('Model.buildRules', ['rules' => $this->_rulesChecker]);
return $this->_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.
*
* @param \Cake\Datasource\RulesChecker $rules The rules object to be modified.
* @return \Cake\Datasource\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
return $rules;
}
}