You are here

public function Thread::query in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/comment/src/Plugin/views/sort/Thread.php \Drupal\comment\Plugin\views\sort\Thread::query()

Called to add the sort to a query.

Overrides SortPluginBase::query

File

core/modules/comment/src/Plugin/views/sort/Thread.php, line 21
Contains \Drupal\comment\Plugin\views\sort\Thread.

Class

Thread
Sort handler for ordering by thread.

Namespace

Drupal\comment\Plugin\views\sort

Code

public function query() {
  $this
    ->ensureMyTable();

  //Read comment_render() in comment.module for an explanation of the

  //thinking behind this sort.
  if ($this->options['order'] == 'DESC') {
    $this->query
      ->addOrderBy($this->tableAlias, $this->realField, $this->options['order']);
  }
  else {
    $alias = $this->tableAlias . '_' . $this->realField . 'asc';

    //@todo is this secure?
    $this->query
      ->addOrderBy(NULL, "SUBSTRING({$this->tableAlias}.{$this->realField}, 1, (LENGTH({$this->tableAlias}.{$this->realField}) - 1))", $this->options['order'], $alias);
  }
}