public function operatorterm(Query $query, TokenInterface $token)
    {
        $terms = explode(',', strtolower($token->value()));
        $conjunction = $token->negated() ? 'NOT IN' : 'IN';

        if (empty($terms)) {
            return $query;
        }

        $conditions = [
            "Contents.id {$conjunction}" => TableRegistry::get('Taxonomy.EntitiesTerms')
                ->find()
                ->select(['EntitiesTerms.entity_id'])
                ->where(['EntitiesTerms.table_alias' => $this->alias()])
                ->matching('Terms', function ($q) use ($terms) {
                    return $q->where(['Terms.slug IN' => $terms]);
                })
        ];

        if (!empty($conditions)) {
            if ($token->where() === 'or') {
                $query->orWhere($conditions);
            } elseif ($token->where() === 'and') {
                $query->andWhere($conditions);
            } else {
                $query->where($conditions);
            }
        }

        return $query;
    }
public function operatorterm(Query $query, TokenInterface $token)
    {
        $terms = explode(',', strtolower($token->value()));
        $conjunction = $token->negated() ? 'NOT IN' : 'IN';

        if (empty($terms)) {
            return $query;
        }

        $conditions = [
            "Contents.id {$conjunction}" => TableRegistry::get('Taxonomy.EntitiesTerms')
                ->find()
                ->select(['EntitiesTerms.entity_id'])
                ->where(['EntitiesTerms.table_alias' => $this->alias()])
                ->matching('Terms', function ($q) use ($terms) {
                    return $q->where(['Terms.slug IN' => $terms]);
                })
        ];

        if (!empty($conditions)) {
            if ($token->where() === 'or') {
                $query->orWhere($conditions);
            } elseif ($token->where() === 'and') {
                $query->andWhere($conditions);
            } else {
                $query->where($conditions);
            }
        }

        return $query;
    }
public function operatorterm ( Query $ query , TokenInterface $ token ) { $ terms = explode ( ',' , strtolower ( $ token -> value ( ) ) ) ; $ conjunction = $ token -> negated ( ) ? 'NOT IN' : 'IN' ; if ( empty ( $ terms ) ) { return $ query ; } $ conditions = [ "Contents.id {$conjunction}" => TableRegistry :: get ( 'Taxonomy.EntitiesTerms' ) -> find ( ) -> select ( [ 'EntitiesTerms.entity_id' ] ) -> where ( [ 'EntitiesTerms.table_alias' => $ this -> alias ( ) ] ) -> matching ( 'Terms' , function ( $ q ) use ( $ terms ) { return $ q -> where ( [ 'Terms.slug IN' => $ terms ] ) ; } ) ] ; if ( ! empty ( $ conditions ) ) { if ( $ token -> where ( ) === 'or' ) { $ query -> orWhere ( $ conditions ) ; } elseif ( $ token -> where ( ) === 'and' ) { $ query -> andWhere ( $ conditions ) ; } else { $ query -> where ( $ conditions ) ; } } return $ query ; }
Handles "term" search operator.

term:term1-slug,term2-slug,...

@param \Cake\ORM\Query $query The query object
@param \Search\Parser\TokenInterface $token Operator token
@return \Cake\ORM\Query
Handles term search operator .