/** * 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); } } }
/** * Creates a new column. * * @param Newscoop\Service\Model\Search\Search $search * The search instance that is the owner of this Column. */ function __construct(Search $search) { Validation::notEmpty($search, 'search'); $this->search = $search; $this->search->register($this); }