public function checkRules(EntityInterface $entity, $operation = RulesChecker::CREATE, $options = null)
    {
        $rules = $this->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;
    }
public function checkRules(EntityInterface $entity, $operation = RulesChecker::CREATE, $options = null)
    {
        $rules = $this->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;
    }
public function checkRules ( EntityInterface $ entity , $ operation = RulesChecker :: CREATE , $ options = null ) { $ rules = $ this -> 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 whether or not the passed entity complies with all the rules stored in
the rules checker.

@param \Cake\Datasource\EntityInterface $entity The entity to check for validity.
@param string $operation The operation being run. Either 'create', 'update' or 'delete'.
@param \ArrayObject|array|null $options The options To be passed to the rules.
@return bool
Returns whether or not the passed entity complies with all the rules stored in the rules checker .