You are here

public function FieldPluginBase::clickSort in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::clickSort()

Adds an ORDER BY clause to the query for click sort columns.

Parameters

string $order: Either ASC or DESC

Overrides FieldHandlerInterface::clickSort

1 method overrides FieldPluginBase::clickSort()
Field::clickSort in core/modules/views/src/Plugin/views/field/Field.php
Called to determine what to tell the clicksorter.

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 207
Contains \Drupal\views\Plugin\views\field\FieldPluginBase.

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function clickSort($order) {
  if (isset($this->field_alias)) {

    // Since fields should always have themselves already added, just
    // add a sort on the field.
    $params = $this->options['group_type'] != 'group' ? array(
      'function' => $this->options['group_type'],
    ) : array();
    $this->query
      ->addOrderBy(NULL, NULL, $order, $this->field_alias, $params);
  }
}