/**
* Builds on to the provided query builder the ordering that will reflect the provided search object.
*
* @param Search $search
* The search from which the query is build, if the search does not reflect any ordering
* no actions needs to be taken, *(not null not empty).
*
* @param QueryBuilder $qb
* The Doctrine query builder to be constructed on, *(not null not empty).
*/
protected function processOrder(Search $search, QueryBuilder $qb)
{
foreach ($search->getOrderedBy() as $column) {
/** @var $column Newscoop\Service\Model\Search\ColumnOrder */
if ($column instanceof ColumnOrder) {
$field = self::ALIAS . '.' . $this->map($search, $column);
if ($column->isOrderAscending() === TRUE) {
$order = 'ASC';
} else {
$order = 'DESC';
}
$qb->addOrderBy($field, $order);
}
}
}