You are here

protected function EmailVerification::queryOpBoolean in User email verification 8

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

Parameters

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

string $query_operator: (optional) Either self::EQUAL or self::NOT_EQUAL. Defaults to self::EQUAL.

File

src/Plugin/views/filter/EmailVerification.php, line 251

Class

EmailVerification
Simple filter to handle matching of boolean values

Namespace

Drupal\user_email_verification\Plugin\views\filter

Code

protected function queryOpBoolean($field, $query_operator = self::EQUAL) {
  if (empty($this->value)) {
    if ($this->accept_null) {
      if ($query_operator === self::EQUAL) {
        $condition = (new Condition('OR'))
          ->condition($field, 0, $query_operator)
          ->isNull($field);
      }
      else {
        $condition = (new Condition('AND'))
          ->condition($field, 0, $query_operator)
          ->isNotNull($field);
      }
      $this->query
        ->addWhere($this->options['group'], $condition);
    }
    else {
      $this->query
        ->addWhere($this->options['group'], $field, 0, $query_operator);
    }
  }
  else {
    if (!empty($this->definition['use_equal'])) {

      // Forces a self::EQUAL operator instead of a self::NOT_EQUAL for
      // performance reasons.
      if ($query_operator === self::EQUAL) {
        $this->query
          ->addWhere($this->options['group'], $field, 0, self::NOT_EQUAL);
      }
      else {
        $this->query
          ->addWhere($this->options['group'], $field, 0, self::EQUAL);
      }
    }
    else {
      $this->query
        ->addWhere($this->options['group'], $field, 0, self::NOT_EQUAL);
    }
  }
}