You are here

public function ElasticsearchViewsStringFilter::operators in Elasticsearch Connector 8.7

Same name and namespace in other branches
  1. 8.5 modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsStringFilter.php \Drupal\elasticsearch_connector_views\Plugin\views\filter\ElasticsearchViewsStringFilter::operators()
  2. 8.6 modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsStringFilter.php \Drupal\elasticsearch_connector_views\Plugin\views\filter\ElasticsearchViewsStringFilter::operators()

Helper function to define opertators.

2 calls to ElasticsearchViewsStringFilter::operators()
ElasticsearchViewsStringFilter::operatorOptions in modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsStringFilter.php
Build strings from the operators() for 'select' options
ElasticsearchViewsStringFilter::operatorValues in modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsStringFilter.php
Helper function to build operator values.

File

modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsStringFilter.php, line 136

Class

ElasticsearchViewsStringFilter
Basic textfield filter to handle string filtering commands including equality, like, not like, etc.

Namespace

Drupal\elasticsearch_connector_views\Plugin\views\filter

Code

public function operators() {
  $operators = array(
    '=' => array(
      'title' => $this
        ->t('Is equal to'),
      'short' => $this
        ->t('='),
      'method' => 'opEqual',
      'values' => 1,
    ),
    '!=' => array(
      'title' => $this
        ->t('Is not equal to'),
      'short' => $this
        ->t('!='),
      'method' => 'opEqual',
      'values' => 1,
    ),
    'word' => array(
      'title' => $this
        ->t('Contains any word'),
      'short' => $this
        ->t('has word'),
      'method' => 'opContainsWord',
      'values' => 1,
    ),
    'allwords' => array(
      'title' => $this
        ->t('Contains all words'),
      'short' => $this
        ->t('has all'),
      'method' => 'opContainsWord',
      'values' => 1,
    ),
    'starts' => array(
      'title' => $this
        ->t('Starts with'),
      'short' => $this
        ->t('begins'),
      'method' => 'opStartsWith',
      'values' => 1,
    ),
  );

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