You are here

protected function SearchApiDate::opBetween in Search API 8

Filters by operator between.

Parameters

object $field: The views field.

Overrides Date::opBetween

File

src/Plugin/views/filter/SearchApiDate.php, line 90

Class

SearchApiDate
Defines a filter for filtering on dates.

Namespace

Drupal\search_api\Plugin\views\filter

Code

protected function opBetween($field) {
  if ($this->value['type'] == 'offset') {
    $time = $this
      ->getTimeService()
      ->getRequestTime();
    $a = strtotime($this->value['min'], $time);
    $b = strtotime($this->value['max'], $time);
  }
  else {
    $a = intval(strtotime($this->value['min'], 0));
    $b = intval(strtotime($this->value['max'], 0));
  }
  $real_field = $this->realField;
  $operator = strtoupper($this->operator);
  $group = $this->options['group'];
  $this
    ->getQuery()
    ->addCondition($real_field, [
    $a,
    $b,
  ], $operator, $group);
}