You are here

protected function BooleanOperator::queryOpBoolean in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::queryOpBoolean()

Adds a where condition to the query for a boolean value.

Parameters

string $field: The field name to add the where condition for.

File

core/modules/views/src/Plugin/views/filter/BooleanOperator.php, line 217
Contains \Drupal\views\Plugin\views\filter\BooleanOperator.

Class

BooleanOperator
Simple filter to handle matching of boolean values

Namespace

Drupal\views\Plugin\views\filter

Code

protected function queryOpBoolean($field) {
  if (empty($this->value)) {
    if ($this->accept_null) {
      $or = db_or()
        ->condition($field, 0, '=')
        ->condition($field, NULL, 'IS NULL');
      $this->query
        ->addWhere($this->options['group'], $or);
    }
    else {
      $this->query
        ->addWhere($this->options['group'], $field, 0, '=');
    }
  }
  else {
    if (!empty($this->definition['use_equal'])) {
      $this->query
        ->addWhere($this->options['group'], $field, 1, '=');
    }
    else {
      $this->query
        ->addWhere($this->options['group'], $field, 0, '<>');
    }
  }
}