You are here

protected function DataProviderDbQuery::defaultSortInfo in RESTful 7.2

Defines default sort columns if none are provided via the request URL.

Return value

array Array keyed by the database column name, and the order ('ASC' or 'DESC') as value.

1 call to DataProviderDbQuery::defaultSortInfo()
DataProviderDbQuery::queryForListSort in src/Plugin/resource/DataProvider/DataProviderDbQuery.php
Sort the query for list.

File

src/Plugin/resource/DataProvider/DataProviderDbQuery.php, line 388
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderDbQuery.

Class

DataProviderDbQuery

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

protected function defaultSortInfo() {
  $sorts = array();
  foreach ($this
    ->getIdColumn() as $column) {
    if (!$this->fieldDefinitions
      ->get($column)) {

      // Sort by the first ID column that is a public field.
      $sorts[$column] = 'ASC';
      break;
    }
  }
  return $sorts;
}