You are here

public function Combine::query in Views (for Drupal 7) 8.3

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

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);
    $seperated_fields = array();
    foreach ($fields as $key => $field) {
      $seperated_fields[] = $field;
      if ($key < $count - 1) {
        $seperated_fields[] = "' '";
      }
    }
    $expression = implode(', ', $seperated_fields);
    $expression = "CONCAT_WS(' ', {$expression})";
    $info = $this
      ->operators();
    if (!empty($info[$this->operator]['method'])) {
      $this
        ->{$info[$this->operator]['method']}($expression);
    }
  }
}