public function SearchApiViewsHandlerFilterEntity::query in Search API 7
Add this filter to the query.
Overrides SearchApiViewsHandlerFilter::query
File
- contrib/
search_api_views/ includes/ handler_filter_entity.inc, line 184 - Contains SearchApiViewsHandlerFilterEntity.
Class
- SearchApiViewsHandlerFilterEntity
- Views filter handler class for entities.
Code
public function query() {
if ($this->operator === 'empty') {
$this->query
->condition($this->real_field, NULL, '=', $this->options['group']);
}
elseif ($this->operator === 'not empty') {
$this->query
->condition($this->real_field, NULL, '<>', $this->options['group']);
}
elseif (is_array($this->value)) {
$all_of = $this->operator === 'all of';
$operator = $all_of ? '=' : $this->operator;
if (count($this->value) == 1) {
$this->query
->condition($this->real_field, reset($this->value), $operator, $this->options['group']);
}
else {
$filter = $this->query
->createFilter($operator === '<>' || $all_of ? 'AND' : 'OR');
foreach ($this->value as $value) {
$filter
->condition($this->real_field, $value, $operator);
}
$this->query
->filter($filter, $this->options['group']);
}
}
}