public function ProximitySort::query in Geolocation Field 8
Same name and namespace in other branches
- 8.3 src/Plugin/views/sort/ProximitySort.php \Drupal\geolocation\Plugin\views\sort\ProximitySort::query()
- 8.2 src/Plugin/views/sort/ProximitySort.php \Drupal\geolocation\Plugin\views\sort\ProximitySort::query()
Called to add the sort to a query.
Overrides SortPluginBase::query
File
- src/
Plugin/ views/ sort/ ProximitySort.php, line 63
Class
- ProximitySort
- Sort handler for geolocaiton field.
Namespace
Drupal\geolocation\Plugin\views\sortCode
public function query() {
if (!$this->query instanceof Sql) {
return;
}
// Get the field for sorting.
$field = isset($this->view->field[$this->options['proximity_field']]) ? $this->view->field[$this->options['proximity_field']] : NULL;
if (!empty($field->field_alias) && $field->field_alias != 'unknown') {
$this->query
->addOrderBy(NULL, NULL, $this->options['order'], $field->field_alias);
$this->tableAlias = $field->tableAlias;
}
}