function GroupByNumeric::opBetween

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/GroupByNumeric.php \Drupal\views\Plugin\views\filter\GroupByNumeric::opBetween()
  2. 8.9.x core/modules/views/src/Plugin/views/filter/GroupByNumeric.php \Drupal\views\Plugin\views\filter\GroupByNumeric::opBetween()
  3. 10 core/modules/views/src/Plugin/views/filter/GroupByNumeric.php \Drupal\views\Plugin\views\filter\GroupByNumeric::opBetween()

Overrides NumericFilter::opBetween

File

core/modules/views/src/Plugin/views/filter/GroupByNumeric.php, line 25

Class

GroupByNumeric
Simple filter to handle greater than/less than filters.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function opBetween($field) {
    $placeholder_min = $this->placeholder();
    $placeholder_max = $this->placeholder();
    if ($this->operator == 'between') {
        $this->query
            ->addHavingExpression($this->options['group'], "{$field} >= {$placeholder_min}", [
            $placeholder_min => $this->value['min'],
        ]);
        $this->query
            ->addHavingExpression($this->options['group'], "{$field} <= {$placeholder_max}", [
            $placeholder_max => $this->value['max'],
        ]);
    }
    else {
        $this->query
            ->addHavingExpression($this->options['group'], "{$field} < {$placeholder_min} OR {$field} > {$placeholder_max}", [
            $placeholder_min => $this->value['min'],
            $placeholder_max => $this->value['max'],
        ]);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.