/**
  * @param SearchQueryBuilder $searchQueryBuilder
  * @param string[]           $emails
  */
 protected function prepareSearchEmailCriteria(SearchQueryBuilder $searchQueryBuilder, $emails = [])
 {
     $searchCriteria = $searchQueryBuilder->getCriteria();
     foreach ($emails as $email) {
         $searchCriteria->orWhere($searchCriteria->expr()->contains('email', $email));
     }
 }
Example #2
0
 /**
  * @param Query $query
  * @param $expr
  */
 protected function addOrganizationLimits(Query $query, $expr)
 {
     $organizationId = $this->getOrganizationId();
     if ($organizationId) {
         $query->getCriteria()->andWhere($expr->in('integer.organization', [$organizationId, SearchListener::EMPTY_ORGANIZATION_ID]));
     }
 }
Example #3
0
 public function testWhere()
 {
     $query = new Query();
     $query->setMappingConfig($this->config);
     $query->from('Oro\\Bundle\\DataBundle\\Entity\\Product');
     $query->where('or', 'all_data', '=', 'test', 'string');
     $whereExpression = $query->getCriteria()->getWhereExpression();
     $this->assertEquals('string.all_data', $whereExpression->getField());
     $this->assertEquals(Comparison::EQ, $whereExpression->getOperator());
     $this->assertEquals('test', $whereExpression->getValue()->getValue());
 }
Example #4
0
 /**
  * Parse max_results statement of expression.
  */
 protected function parseMaxResultsExpression()
 {
     $this->stream->next();
     /** @var Token $token */
     $token = $this->stream->current;
     if ($token->test(Token::NUMBER_TYPE)) {
         $this->query->getCriteria()->setMaxResults($token->value);
         $this->stream->next();
     } else {
         throw new ExpressionSyntaxError(sprintf('Unexpected token "%s", value "%s" in offset statements', $token->type, $token->value), $token->cursor);
     }
 }
Example #5
0
 /**
  * Set order by for search query
  *
  * @param \Oro\Bundle\SearchBundle\Query\Query $query
  * @param \Doctrine\ORM\QueryBuilder           $qb
  */
 protected function addOrderBy(Query $query, QueryBuilder $qb)
 {
     $orderBy = $query->getCriteria()->getOrderings();
     if ($orderBy) {
         $direction = reset($orderBy);
         list($fieldType, $fieldName) = Criteria::explodeFieldTypeName(key($orderBy));
         $orderRelation = $fieldType . 'Fields';
         $qb->leftJoin('search.' . $orderRelation, 'orderTable', 'WITH', 'orderTable.field = :orderField')->orderBy('orderTable.value', $direction)->setParameter('orderField', $fieldName);
     }
 }