You are here

protected function RestfulDataProviderDbQuery::queryForListSort in RESTful 7

Sort the query for list.

Parameters

\SelectQuery $query: The query object.

Throws

\RestfulBadRequestException

See also

\RestfulEntityBase::getQueryForList

1 call to RestfulDataProviderDbQuery::queryForListSort()
RestfulDataProviderDbQuery::getQueryForList in plugins/restful/RestfulDataProviderDbQuery.php
Prepare a query for RestfulEntityBase::getList().

File

plugins/restful/RestfulDataProviderDbQuery.php, line 172
Contains \RestfulDataProviderDbQuery

Class

RestfulDataProviderDbQuery
@file Contains \RestfulDataProviderDbQuery

Code

protected function queryForListSort(\SelectQuery $query) {
  $public_fields = $this
    ->getPublicFields();

  // Get the sorting options from the request object.
  $sorts = $this
    ->parseRequestForListSort();
  $sorts = $sorts ? $sorts : $this
    ->defaultSortInfo();
  foreach ($sorts as $sort => $direction) {
    $column_name = $this
      ->getPropertyColumnForQuery($public_fields[$sort]);
    $query
      ->orderBy($column_name, $direction);
  }
}