You are here

public function BoundaryFilter::query in Geolocation Field 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/filter/BoundaryFilter.php \Drupal\geolocation\Plugin\views\filter\BoundaryFilter::query()
  2. 8.2 src/Plugin/views/filter/BoundaryFilter.php \Drupal\geolocation\Plugin\views\filter\BoundaryFilter::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides FilterPluginBase::query

File

src/Plugin/views/filter/BoundaryFilter.php, line 332

Class

BoundaryFilter
Filter handler for search keywords.

Namespace

Drupal\geolocation\Plugin\views\filter

Code

public function query() {
  if (!$this->query instanceof Sql) {
    return;
  }
  if (empty($this->value)) {
    return;
  }

  // Get the field alias.
  $lat_north_east = $this->value['lat_north_east'];
  $lng_north_east = $this->value['lng_north_east'];
  $lat_south_west = $this->value['lat_south_west'];
  $lng_south_west = $this->value['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($this->options['group'], $this->geolocationCore
    ->getBoundaryQueryFragment($this
    ->ensureMyTable(), $this->realField, $lat_north_east, $lng_north_east, $lat_south_west, $lng_south_west));
}