/** * @param Query $query * @param SortConfig $sortConfig */ protected function applyESSort(Query $query, SortConfig $sortConfig) { $column = $sortConfig->getColumn(); if ($column) { $direction = $sortConfig->getDirection() ? 'desc' : 'asc'; // null or false both default to ASC $query->addSort([$column => ['order' => $direction]]); } }
/** * @param QueryBuilder $qb * @param SortConfig $sortConfig */ protected function applySort(QueryBuilder $qb, SortConfig $sortConfig) { $column = $sortConfig->getColumn(); if ($column) { $fullColumnReference = $column; if (false === strpos($column, '.')) { $fullColumnReference = $this->alias . '.' . $column; } $direction = $sortConfig->getDirection() ? 'DESC' : 'ASC'; // null or false both default to ASC $qb->addOrderBy($fullColumnReference, $direction); } }
/** * @param QueryBuilder $qb * @param SortConfig $sortConfig */ protected function applySort(QueryBuilder $qb, SortConfig $sortConfig) { $column = $sortConfig->getColumn(); if (!$column || !$this->family->hasAttribute($column)) { parent::applySort($qb, $sortConfig); return; } $attribute = $this->family->getAttribute($column); $uid = uniqid('join'); $fullColumnReference = $uid . '.' . $attribute->getType()->getDatabaseType(); $qb->leftJoin($this->alias . '.values', $uid, Join::WITH, "({$uid}.data = {$this->alias}.id AND ({$uid}.attributeCode = '{$attribute->getCode()}' OR {$uid}.id IS NULL))"); $direction = $sortConfig->getDirection() ? 'DESC' : 'ASC'; // null or false both default to ASC $qb->addOrderBy($fullColumnReference, $direction); }