public function Natural::query in Views Natural Sort 8.2
Called to add the sort to a query.
Overrides SortPluginBase::query
File
- src/
Plugin/ views/ sort/ Natural.php, line 37
Class
- Natural
- Sort plugin used to allow Natural Sorting.
Namespace
Drupal\views_natural_sort\Plugin\views\sortCode
public function query() {
// If this field isn't being used as a Natural Sort Field, move along
// nothing to see here.
if (!$this
->isNaturalSort()) {
parent::query();
return;
}
// Add the Views Natural Sort table for this field.
$vns_alias = 'vns_' . $this->tableAlias;
if (empty($this->query->relationships[$vns_alias])) {
$this
->ensureMyTable();
$vns_alias = $this->query
->addRelationship('vns_' . $this->tableAlias, $this
->naturalSortJoin(), $this->table, $this->relationship);
}
$this->query
->addOrderBy($vns_alias, 'content', substr($this->options['order'], 1));
}