addSearchTermCondition example

/** * @return SearcherResult */
    public function search(SearchCriteria $criteria)
    {
        $builder = $this->createQuery($criteria);

        $builder->setFirstResult($criteria->offset)
            ->setMaxResults($criteria->limit);

        if ($criteria->term) {
            $this->addSearchTermCondition($criteria$builder);
        }
        if ($criteria->conditions) {
            $builder->addFilter($criteria->conditions);
        }
        if ($criteria->sortings) {
            $builder->addOrderBy($criteria->sortings);
        }

        return $this->createResult($builder);
    }

    
$limit = $this->Request()->getParam('limit', 20);

        $builder = $this->createEntitySearchQuery($entity);

        if (!empty($ids)) {
            $ids = json_decode($ids, true);
            $this->addIdsCondition($builder$ids);
        } elseif (!empty($id)) {
            $this->addIdsCondition($builder[$id]);
        } else {
            if (!empty($term)) {
                $this->addSearchTermCondition($entity$builder$term);
            }

            $builder->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $pagination = $this->getPaginator($builder);
        $data = iterator_to_array($pagination);

        $data = $this->hydrateSearchResult($entity$data);

        
Home | Imprint | This part of the site doesn't use cookies.