public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
    {
        $field = $this->getTrashField();
        $addCondition = true;

        $query->traverseExpressions(function ($expression) use (&$addCondition, $field) {
            if (!$addCondition) {
                return;
            }

            if ($expression instanceof IdentifierExpression
                && $expression->getIdentifier() === $field
            ) {
                $addCondition = false;

                return;
            }

            if (($expression instanceof Comparison || $expression instanceof BetweenExpression)
                && $expression->getField() === $field
            ) {
                $addCondition = false;
            }
        });

        if ($addCondition) {
            $query->andWhere($query->newExpr()->isNull($field));
        }
    }
public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
    {
        $field = $this->getTrashField();
        $addCondition = true;

        $query->traverseExpressions(function ($expression) use (&$addCondition, $field) {
            if (!$addCondition) {
                return;
            }

            if ($expression instanceof IdentifierExpression
                && $expression->getIdentifier() === $field
            ) {
                $addCondition = false;

                return;
            }

            if (($expression instanceof Comparison || $expression instanceof BetweenExpression)
                && $expression->getField() === $field
            ) {
                $addCondition = false;
            }
        });

        if ($addCondition) {
            $query->andWhere($query->newExpr()->isNull($field));
        }
    }
public function beforeFind ( Event $ event , Query $ query , ArrayObject $ options , $ primary ) { $ field = $ this -> getTrashField ( ) ; $ addCondition = true ; $ query -> traverseExpressions ( function ( $ expression ) use ( & $ addCondition , $ field ) { if ( ! $ addCondition ) { return ; } if ( $ expression instanceof IdentifierExpression && $ expression -> getIdentifier ( ) === $ field ) { $ addCondition = false ; return ; } if ( ( $ expression instanceof Comparison || $ expression instanceof BetweenExpression ) && $ expression -> getField ( ) === $ field ) { $ addCondition = false ; } } ) ; if ( $ addCondition ) { $ query -> andWhere ( $ query -> newExpr ( ) -> isNull ( $ field ) ) ; } }
Callback to always return rows that have not been `trashed`.

@param \Cake\Event\Event $event Event.
@param \Cake\ORM\Query $query Query.
@param \ArrayObject $options Options.
@param bool $primary Primary or associated table being queries.
@return void
Callback to always return rows that have not been trashed .