public function SearchApiViewsHandlerFilterNumeric::query in Search API 7
Add this filter to the query.
Overrides SearchApiViewsHandlerFilter::query
1 method overrides SearchApiViewsHandlerFilterNumeric::query()
- SearchApiViewsHandlerFilterDate::query in contrib/
search_api_views/ includes/ handler_filter_date.inc - Add this filter to the query.
File
- contrib/
search_api_views/ includes/ handler_filter_numeric.inc, line 202 - Contains SearchApiViewsHandlerFilterNumeric.
Class
- SearchApiViewsHandlerFilterNumeric
- Views filter handler class for handling numeric and "string" fields.
Code
public function query() {
$this
->normalizeValue();
if (in_array($this->operator, array(
'between',
'not between',
), TRUE)) {
$min = $this->value['min'];
$max = $this->value['max'];
if ($min !== '' && $max !== '') {
$this->query
->condition($this->real_field, array(
$min,
$max,
), strtoupper($this->operator), $this->options['group']);
}
elseif ($min !== '') {
$operator = $this->operator === 'between' ? '>=' : '<';
$this->query
->condition($this->real_field, $min, $operator, $this->options['group']);
}
elseif ($max !== '') {
$operator = $this->operator === 'between' ? '<=' : '>';
$this->query
->condition($this->real_field, $max, $operator, $this->options['group']);
}
}
else {
// The parent handler doesn't expect our value structure, just pass the
// scalar value instead.
$this->value = $this->value['value'];
parent::query();
}
}