You are here

protected function GeofieldProximityFilter::opBetween in Geofield 8

Filters by operator between.

Parameters

object $field: The views field.

Overrides NumericFilter::opBetween

File

src/Plugin/views/filter/GeofieldProximityFilter.php, line 228

Class

GeofieldProximityFilter
Field handler to filter Geofields by proximity.

Namespace

Drupal\geofield\Plugin\views\filter

Code

protected function opBetween($options) {
  if (!empty($this->value['min']) && is_numeric($this->value['min']) && !empty($this->value['max']) && is_numeric($this->value['max'])) {

    // Be sure to convert $options into array,
    // as this method PhpDoc might expects $options to be an object.
    $options = (array) $options;

    /* @var array $options */
    $this->query
      ->addWhereExpression($this->options['group'], geofield_haversine($options) . ' ' . strtoupper($this->operator) . ' ' . $this->value['min'] . ' AND ' . $this->value['max']);
  }
}