You are here

public function BoundaryArgument::query in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/argument/BoundaryArgument.php \Drupal\geolocation\Plugin\views\argument\BoundaryArgument::query()

Set up the query for this argument.

The argument sent may be found at $this->argument.

Overrides ArgumentPluginBase::query

File

src/Plugin/views/argument/BoundaryArgument.php, line 35

Class

BoundaryArgument
Argument handler for geolocation boundary.

Namespace

Drupal\geolocation\Plugin\views\argument

Code

public function query($group_by = FALSE) {
  $values = $this
    ->getParsedBoundary();
  if (!$this->query instanceof Sql) {
    return;
  }
  if (empty($values)) {
    return;
  }

  // Get the field alias.
  $lat_north_east = $values['lat_north_east'];
  $lng_north_east = $values['lng_north_east'];
  $lat_south_west = $values['lat_south_west'];
  $lng_south_west = $values['lng_south_west'];
  if (!is_numeric($lat_north_east) || !is_numeric($lng_north_east) || !is_numeric($lat_south_west) || !is_numeric($lng_south_west)) {
    return;
  }
  $this->query
    ->addWhereExpression($group_by, self::getBoundaryQueryFragment($this
    ->ensureMyTable(), $this->realField, $lat_north_east, $lng_north_east, $lat_south_west, $lng_south_west));
}