protected function _scopeWords(Query $query, TokenInterface $token)
    {
        if ($this->_isFullTextEnabled()) {
            return $this->_scopeWordsInFulltext($query, $token);
        }

        $like = 'LIKE';
        if ($token->negated()) {
            $like = 'NOT LIKE';
        }

        // * Matches any one or more characters.
        // ! Matches any single character.
        $value = str_replace(['*', '!'], ['%', '_'], $token->value());

        if ($token->where() === 'or') {
            $query->orWhere(["SearchDatasets.words {$like}" => "%{$value}%"]);
        } elseif ($token->where() === 'and') {
            $query->andWhere(["SearchDatasets.words {$like}" => "%{$value}%"]);
        } else {
            $query->where(["SearchDatasets.words {$like}" => "%{$value}%"]);
        }

        return $query;
    }
protected function _scopeWords(Query $query, TokenInterface $token)
    {
        if ($this->_isFullTextEnabled()) {
            return $this->_scopeWordsInFulltext($query, $token);
        }

        $like = 'LIKE';
        if ($token->negated()) {
            $like = 'NOT LIKE';
        }

        // * Matches any one or more characters.
        // ! Matches any single character.
        $value = str_replace(['*', '!'], ['%', '_'], $token->value());

        if ($token->where() === 'or') {
            $query->orWhere(["SearchDatasets.words {$like}" => "%{$value}%"]);
        } elseif ($token->where() === 'and') {
            $query->andWhere(["SearchDatasets.words {$like}" => "%{$value}%"]);
        } else {
            $query->where(["SearchDatasets.words {$like}" => "%{$value}%"]);
        }

        return $query;
    }
protected function _scopeWords ( Query $ query , TokenInterface $ token ) { if ( $ this -> _isFullTextEnabled ( ) ) { return $ this -> _scopeWordsInFulltext ( $ query , $ token ) ; } $ like = 'LIKE' ; if ( $ token -> negated ( ) ) { $ like = 'NOT LIKE' ; } // * Matches any one or more characters. // ! Matches any single character. $ value = str_replace ( [ '*' , '!' ] , [ '%' , '_' ] , $ token -> value ( ) ) ; if ( $ token -> where ( ) === 'or' ) { $ query -> orWhere ( [ "SearchDatasets.words {$like}" => "%{$value}%" ] ) ; } elseif ( $ token -> where ( ) === 'and' ) { $ query -> andWhere ( [ "SearchDatasets.words {$like}" => "%{$value}%" ] ) ; } else { $ query -> where ( [ "SearchDatasets.words {$like}" => "%{$value}%" ] ) ; } return $ query ; }
Scopes the given query using the given words token.

@param \Cake\ORM\Query $query The query to scope
@param \Search\TokenInterface $token Token describing a words sequence. e.g `this is a phrase`
@return \Cake\ORM\Query Scoped query
Scopes the given query using the given words token .