/** * {@inheritdoc} */ public function walkComparison(Comparison $comparison) { list($type, $field) = Criteria::explodeFieldTypeName($comparison->getField()); $value = $comparison->getValue()->getValue(); if (is_array($value)) { $value = sprintf('(%s)', implode(', ', $value)); } if ($type === Query::TYPE_TEXT) { $value = sprintf('"%s"', $value); } return sprintf('%s %s %s %s', $type, $field, Criteria::getSearchOperatorByComparisonOperator($comparison->getOperator()), $value); }
/** * @param string $fieldString * * @return array */ protected function explodeCombinedFieldString($fieldString) { list($type, $field) = Criteria::explodeFieldTypeName($fieldString); if (strpos($field, '|') !== false) { $field = explode('|', $field); } return [$type, $field]; }
/** * 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); } }
/** * Get "order by" field type * * @deprecated Since 1.8 use criteria's getOrderings method * * @return string */ public function getOrderType() { $orders = array_keys($this->criteria->getOrderings()); $fieldName = array_pop($orders); return Criteria::explodeFieldTypeName($fieldName)[0]; }