function String::operators

This kind of construct makes it relatively easy for a child class to add or remove functionality by overriding this function and adding/removing items from this array.

4 calls to String::operators()
Combine::query in drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/Combine.php
Add this filter to the query.
String::operatorOptions in drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php
Build strings from the operators() for 'select' options
String::operatorValues in drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php
String::query in drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php
Add this filter to the query.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php, line 39
Definition of Drupal\views\Plugin\views\filter\String.

Class

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

Namespace

Drupal\views\Plugin\views\filter

Code

function operators() {
  $operators = array(
    '=' => array(
      'title' => t('Is equal to'),
      'short' => t('='),
      'method' => 'opEqual',
      'values' => 1,
    ),
    '!=' => array(
      'title' => t('Is not equal to'),
      'short' => t('!='),
      'method' => 'opEqual',
      'values' => 1,
    ),
    'contains' => array(
      'title' => t('Contains'),
      'short' => t('contains'),
      'method' => 'opContains',
      'values' => 1,
    ),
    'word' => array(
      'title' => t('Contains any word'),
      'short' => t('has word'),
      'method' => 'opContainsWord',
      'values' => 1,
    ),
    'allwords' => array(
      'title' => t('Contains all words'),
      'short' => t('has all'),
      'method' => 'opContainsWord',
      'values' => 1,
    ),
    'starts' => array(
      'title' => t('Starts with'),
      'short' => t('begins'),
      'method' => 'opStartsWith',
      'values' => 1,
    ),
    'not_starts' => array(
      'title' => t('Does not start with'),
      'short' => t('not_begins'),
      'method' => 'opNotStartsWith',
      'values' => 1,
    ),
    'ends' => array(
      'title' => t('Ends with'),
      'short' => t('ends'),
      'method' => 'opEndsWith',
      'values' => 1,
    ),
    'not_ends' => array(
      'title' => t('Does not end with'),
      'short' => t('not_ends'),
      'method' => 'opNotEnds',
      'values' => 1,
    ),
    'not' => array(
      'title' => t('Does not contain'),
      'short' => t('!has'),
      'method' => 'opNotLike',
      'values' => 1,
    ),
    'shorterthan' => array(
      'title' => t('Length is shorter than'),
      'short' => t('shorter than'),
      'method' => 'opShorterThan',
      'values' => 1,
    ),
    'longerthan' => array(
      'title' => t('Length is longer than'),
      'short' => t('longer than'),
      'method' => 'opLongerThan',
      'values' => 1,
    ),
  );

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

  // Add regexp support for MySQL.
  if (Database::getConnection()
    ->databaseType() == 'mysql') {
    $operators += array(
      'regular_expression' => array(
        'title' => t('Regular expression'),
        'short' => t('regex'),
        'method' => 'opRegex',
        'values' => 1,
      ),
    );
  }
  return $operators;
}