You are here

public function ProximityArgument::query in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/views/argument/ProximityArgument.php \Drupal\geolocation\Plugin\views\argument\ProximityArgument::query()
  2. 8.2 src/Plugin/views/argument/ProximityArgument.php \Drupal\geolocation\Plugin\views\argument\ProximityArgument::query()

Build the query based upon the formula

Overrides Formula::query

File

src/Plugin/views/argument/ProximityArgument.php, line 77

Class

ProximityArgument
Argument handler for geolocation proximity.

Namespace

Drupal\geolocation\Plugin\views\argument

Code

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

  // Now that our table is secure, get our formula.
  $placeholder = $this
    ->placeholder();
  $formula = $this
    ->getFormula();
  if (!$formula) {
    return;
  }
  $formula .= ' ' . $this->operator . ' ' . $placeholder;
  $placeholders = [
    $placeholder => $this->distance,
  ];

  // The addWhere function is only available for SQL queries.
  if ($this->query instanceof Sql) {
    $this->query
      ->addWhere(0, $formula, $placeholders, 'formula');
  }
}