Newscoop\Service\Model\Search\Search::getOrderedBy PHP Method

getOrderedBy() public method

The order in the array will be the order in which the columns have been specified for ordering.
public getOrderedBy ( ) : array
return array The arrays containing the Columns to be ordered by.
    public function getOrderedBy()
    {
        return $this->orderBy;
    }

Usage Example

 /**
  *  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);
         }
     }
 }