public function Combine::query

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides String::query

File

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

Class

Combine
Filter handler which allows to search on multiple fields.

Namespace

Drupal\views\Plugin\views\filter

Code

public function query() {
  $this->view
    ->_build('field');
  $fields = array();

  // Only add the fields if they have a proper field and table alias.
  foreach ($this->options['fields'] as $id) {
    $field = $this->view->field[$id];

    // Always add the table of the selected fields to be sure a table alias exists.
    $field
      ->ensureMyTable();
    if (!empty($field->field_alias) && !empty($field->field_alias)) {
      $fields[] = "{$field->tableAlias}.{$field->realField}";
    }
  }
  if ($fields) {
    $count = count($fields);
    $separated_fields = array();
    foreach ($fields as $key => $field) {
      $separated_fields[] = $field;
      if ($key < $count - 1) {
        $separated_fields[] = "' '";
      }
    }
    $expression = implode(', ', $separated_fields);
    $expression = "CONCAT_WS(' ', {$expression})";
    $info = $this
      ->operators();
    if (!empty($info[$this->operator]['method'])) {
      $this
        ->{$info[$this->operator]['method']}($expression);
    }
  }
}