You are here

public function NumericFilter::operators in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::operators()
9 calls to NumericFilter::operators()
Date::acceptExposedInput in core/modules/views/src/Plugin/views/filter/Date.php
Do some minor translation of the exposed input.
Date::hasValidGroupedValue in core/modules/views/src/Plugin/views/filter/Date.php
Determines if the given grouped filter entry has a valid value.
Date::validateValidTime in core/modules/views/src/Plugin/views/filter/Date.php
Validate that the time values convert to something usable.
GroupByNumeric::query in core/modules/views/src/Plugin/views/filter/GroupByNumeric.php
Add this filter to the query.
NumericFilter::acceptExposedInput in core/modules/views/src/Plugin/views/filter/NumericFilter.php
Do some minor translation of the exposed input.

... See full list

File

core/modules/views/src/Plugin/views/filter/NumericFilter.php, line 92

Class

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

Namespace

Drupal\views\Plugin\views\filter

Code

public function operators() {
  $operators = [
    '<' => [
      'title' => $this
        ->t('Is less than'),
      'method' => 'opSimple',
      'short' => $this
        ->t('<'),
      'values' => 1,
    ],
    '<=' => [
      'title' => $this
        ->t('Is less than or equal to'),
      'method' => 'opSimple',
      'short' => $this
        ->t('<='),
      'values' => 1,
    ],
    '=' => [
      'title' => $this
        ->t('Is equal to'),
      'method' => 'opSimple',
      'short' => $this
        ->t('='),
      'values' => 1,
    ],
    '!=' => [
      'title' => $this
        ->t('Is not equal to'),
      'method' => 'opSimple',
      'short' => $this
        ->t('!='),
      'values' => 1,
    ],
    '>=' => [
      'title' => $this
        ->t('Is greater than or equal to'),
      'method' => 'opSimple',
      'short' => $this
        ->t('>='),
      'values' => 1,
    ],
    '>' => [
      'title' => $this
        ->t('Is greater than'),
      'method' => 'opSimple',
      'short' => $this
        ->t('>'),
      'values' => 1,
    ],
    'between' => [
      'title' => $this
        ->t('Is between'),
      'method' => 'opBetween',
      'short' => $this
        ->t('between'),
      'values' => 2,
    ],
    'not between' => [
      'title' => $this
        ->t('Is not between'),
      'method' => 'opBetween',
      'short' => $this
        ->t('not between'),
      'values' => 2,
    ],
    'regular_expression' => [
      'title' => $this
        ->t('Regular expression'),
      'short' => $this
        ->t('regex'),
      'method' => 'opRegex',
      'values' => 1,
    ],
  ];

  // if the definition allows for the empty operator, add it.
  if (!empty($this->definition['allow empty'])) {
    $operators += [
      'empty' => [
        'title' => $this
          ->t('Is empty (NULL)'),
        'method' => 'opEmpty',
        'short' => $this
          ->t('empty'),
        'values' => 0,
      ],
      'not empty' => [
        'title' => $this
          ->t('Is not empty (NOT NULL)'),
        'method' => 'opEmpty',
        'short' => $this
          ->t('not empty'),
        'values' => 0,
      ],
    ];
  }
  return $operators;
}