Version 1
[yaffs-website] / web / core / modules / views / src / Plugin / views / filter / BooleanOperatorString.php
1 <?php
2
3 namespace Drupal\views\Plugin\views\filter;
4
5 /**
6  * Simple filter to handle matching of boolean values.
7  *
8  * This handler checks to see if a string field is empty (equal to '') or not.
9  * It is otherwise identical to the parent operator.
10  *
11  * Definition items:
12  * - label: (REQUIRED) The label for the checkbox.
13  *
14  * @ingroup views_filter_handlers
15  *
16  * @ViewsFilter("boolean_string")
17  */
18 class BooleanOperatorString extends BooleanOperator {
19
20   public function query() {
21     $this->ensureMyTable();
22     $where = "$this->tableAlias.$this->realField ";
23
24     if (empty($this->value)) {
25       $where .= "= ''";
26       if ($this->accept_null) {
27         $where = '(' . $where . " OR $this->tableAlias.$this->realField IS NULL)";
28       }
29     }
30     else {
31       $where .= "<> ''";
32     }
33     $this->query->addWhereExpression($this->options['group'], $where);
34   }
35
36 }