orderBy() public method

public orderBy ( $column, $direction = ICollection::ASC )
Beispiel #1
0
 /**
  * Sort data
  * @param  Sorting $sorting
  * @return static
  */
 public function sort(Sorting $sorting)
 {
     if (is_callable($sorting->getSortCallback())) {
         call_user_func($sorting->getSortCallback(), $this->data_source, $sorting->getSort());
         return $this;
     }
     $sort = $sorting->getSort();
     if (!empty($sort)) {
         foreach ($sort as $column => $order) {
             $this->data_source = $this->data_source->orderBy($column, $order);
         }
     } else {
         /**
          * Has the statement already a order by clause?
          */
         $order = $this->data_source->getQueryBuilder()->getClause('order');
         if (ArraysHelper::testEmpty($order)) {
             $this->data_source = $this->data_source->orderBy($this->primary_key);
         }
     }
     return $this;
 }