You are here

function Table::build_sort in Views (for Drupal 7) 8.3

Determine if we should provide sorting based upon $_GET inputs

Return value

bool

Overrides StylePluginBase::build_sort

File

lib/Drupal/views/Plugin/views/style/Table.php, line 82
Definition of Drupal\views\Plugin\views\style\Table.

Class

Table
Style plugin to render each item as a row in a table.

Namespace

Drupal\views\Plugin\views\style

Code

function build_sort() {
  $order = drupal_container()
    ->get('request')->query
    ->get('order');
  if (!isset($order) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) {
    return TRUE;
  }

  // If a sort we don't know anything about gets through, exit gracefully.
  if (isset($order) && empty($this->view->field[$order])) {
    return TRUE;
  }

  // Let the builder know whether or not we're overriding the default sorts.
  return empty($this->options['override']);
}