You are here

public function ExpressionSort::query in Views Sort Expression 8

Called to add the sort to a query.

Overrides SortPluginBase::query

File

src/Plugin/views/sort/ExpressionSort.php, line 56

Class

ExpressionSort
Allows to use any SQL expression

Namespace

Drupal\views_sort_expression\Plugin\views\sort

Code

public function query() {
  if (!empty($this->options['expression'])) {
    $alias = $this->realField . '_' . $this->position;
    $this->query
      ->addOrderBy(NULL, $this->options['expression'], $this->options['order'], $alias);
  }
}