public function Combine::query in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/filter/Combine.php \Drupal\views\Plugin\views\filter\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 StringFilter::query
File
- core/
modules/ views/ src/ Plugin/ views/ filter/ Combine.php, line 59 - Contains \Drupal\views\Plugin\views\filter\Combine.
Class
- Combine
- Filter handler which allows to search on multiple fields.
Namespace
Drupal\views\Plugin\views\filterCode
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) {
// Overridden fields can lead to fields missing from a display that are
// still set in the non-overridden combined filter.
if (!isset($this->view->field[$id])) {
// If fields are no longer available that are needed to filter by, make
// sure no results are shown to prevent displaying more then intended.
$this->view->build_info['fail'] = TRUE;
continue;
}
$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);
}
}
}