public function QueryBase::tableSort

Implements Drupal\Core\Entity\Query\QueryInterface::tableSort().

Overrides QueryInterface::tableSort

File

drupal/core/lib/Drupal/Core/Entity/Query/QueryBase.php, line 217
Definition of Drupal\Core\Entity\Query\QueryBase.

Class

QueryBase
The base entity query class.

Namespace

Drupal\Core\Entity\Query

Code

public function tableSort(&$headers) {

  // If 'field' is not initialized, the header columns aren't clickable.
  foreach ($headers as $key => $header) {
    if (is_array($header) && isset($header['specifier'])) {
      $headers[$key]['field'] = '';
    }
  }
  $order = tablesort_get_order($headers);
  $direction = tablesort_get_sort($headers);
  foreach ($headers as $header) {
    if (is_array($header) && $header['data'] == $order['name']) {
      $this
        ->sort($header['specifier'], $direction, isset($header['langcode']) ? $header['langcode'] : NULL);
    }
  }
  return $this;
}