public function ViewsJsonFilter::operators in Views Json Source 8
Same name and namespace in other branches
- 1.x src/Plugin/views/filter/ViewsJsonFilter.php \Drupal\views_json_source\Plugin\views\filter\ViewsJsonFilter::operators()
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.
2 calls to ViewsJsonFilter::operators()
- ViewsJsonFilter::operatorOptions in src/
Plugin/ views/ filter/ ViewsJsonFilter.php - Build strings from the operators() for 'select' options.
- ViewsJsonFilter::operatorValues in src/
Plugin/ views/ filter/ ViewsJsonFilter.php
File
- src/
Plugin/ views/ filter/ ViewsJsonFilter.php, line 33
Class
- ViewsJsonFilter
- Base filter handler for views_json_source.
Namespace
Drupal\views_json_source\Plugin\views\filterCode
public function operators() {
$operators = [
'=' => [
'title' => $this
->t('Is equal to'),
'short' => $this
->t('='),
'method' => 'opEqual',
'values' => 1,
],
'!=' => [
'title' => $this
->t('Is not equal to'),
'short' => $this
->t('!='),
'method' => 'opEqual',
'values' => 1,
],
'contains' => [
'title' => $this
->t('Contains'),
'short' => $this
->t('contains'),
'method' => 'opContains',
'values' => 1,
],
'word' => [
'title' => $this
->t('Contains any word'),
'short' => $this
->t('has word'),
'method' => 'opContainsWord',
'values' => 1,
],
'allwords' => [
'title' => $this
->t('Contains all words'),
'short' => $this
->t('has all'),
'method' => 'opContainsWord',
'values' => 1,
],
'starts' => [
'title' => $this
->t('Starts with'),
'short' => $this
->t('begins'),
'method' => 'opStartsWith',
'values' => 1,
],
'not_starts' => [
'title' => $this
->t('Does not start with'),
'short' => $this
->t('not_begins'),
'method' => 'opNotStartsWith',
'values' => 1,
],
'ends' => [
'title' => $this
->t('Ends with'),
'short' => $this
->t('ends'),
'method' => 'opEndsWith',
'values' => 1,
],
'not_ends' => [
'title' => $this
->t('Does not end with'),
'short' => $this
->t('not_ends'),
'method' => 'opNotEndsWith',
'values' => 1,
],
'not' => [
'title' => $this
->t('Does not contain'),
'short' => $this
->t('!has'),
'method' => 'opNotLike',
'values' => 1,
],
'shorterthan' => [
'title' => $this
->t('Length is shorter than'),
'short' => $this
->t('shorter than'),
'method' => 'opShorterThan',
'values' => 1,
],
'longerthan' => [
'title' => $this
->t('Length is longer than'),
'short' => $this
->t('longer than'),
'method' => 'opLongerThan',
'values' => 1,
],
'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;
}