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);
24 protected function opBetween($field) {
25 $placeholder_min = $this->placeholder();
26 $placeholder_max = $this->placeholder();
27 if ($this->operator == 'between') {
28 $this->query->addHavingExpression($this->options['group'], "$field >= $placeholder_min", [$placeholder_min => $this->value['min']]);
29 $this->query->addHavingExpression($this->options['group'], "$field <= $placeholder_max", [$placeholder_max => $this->value['max']]);
32 $this->query->addHavingExpression($this->options['group'], "$field < $placeholder_min OR $field > $placeholder_max", [$placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']]);
36 protected function opSimple($field) {
37 $placeholder = $this->placeholder();
38 $this->query->addHavingExpression($this->options['group'], "$field $this->operator $placeholder", [$placeholder => $this->value['value']]);
41 protected function opEmpty($field) {
42 if ($this->operator == 'empty') {
43 $operator = "IS NULL";
46 $operator = "IS NOT NULL";
49 $this->query->addHavingExpression($this->options['group'], "$field $operator");
52 public function adminLabel($short = FALSE) {
53 return $this->getField(parent::adminLabel($short));
56 public function canGroup() {