3 namespace Drupal\views\Plugin\views\filter;
6 * Simple filter to handle greater than/less than filters
8 * @ingroup views_filter_handlers
10 * @ViewsFilter("groupby_numeric")
12 class GroupByNumeric extends NumericFilter {
14 public function query() {
15 $this->ensureMyTable();
16 $field = $this->getField();
18 $info = $this->operators();
19 if (!empty($info[$this->operator]['method'])) {
20 $this->{$info[$this->operator]['method']}($field);
23 protected function opBetween($field) {
24 $placeholder_min = $this->placeholder();
25 $placeholder_max = $this->placeholder();
26 if ($this->operator == 'between') {
27 $this->query->addHavingExpression($this->options['group'], "$field >= $placeholder_min", [$placeholder_min => $this->value['min']]);
28 $this->query->addHavingExpression($this->options['group'], "$field <= $placeholder_max", [$placeholder_max => $this->value['max']]);
31 $this->query->addHavingExpression($this->options['group'], "$field < $placeholder_min OR $field > $placeholder_max", [$placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']]);
35 protected function opSimple($field) {
36 $placeholder = $this->placeholder();
37 $this->query->addHavingExpression($this->options['group'], "$field $this->operator $placeholder", [$placeholder => $this->value['value']]);
40 protected function opEmpty($field) {
41 if ($this->operator == 'empty') {
42 $operator = "IS NULL";
45 $operator = "IS NOT NULL";
48 $this->query->addHavingExpression($this->options['group'], "$field $operator");
51 public function adminLabel($short = FALSE) {
52 return $this->getField(parent::adminLabel($short));
55 public function canGroup() {