protected function SearchApiQuery::transformDbCondition in Search API 8
Transforms a database condition to an equivalent search filter.
Parameters
\Drupal\Core\Database\Query\ConditionInterface $db_condition: The condition to transform.
Return value
\Drupal\search_api\Query\ConditionGroupInterface|null A search filter equivalent to $condition, or NULL if the transformation failed.
1 call to SearchApiQuery::transformDbCondition()
- SearchApiQuery::addWhere in src/
Plugin/ views/ query/ SearchApiQuery.php - Adds a simple condition to the query.
File
- src/
Plugin/ views/ query/ SearchApiQuery.php, line 1160
Class
- SearchApiQuery
- Defines a Views query class for searching on Search API indexes.
Namespace
Drupal\search_api\Plugin\views\queryCode
protected function transformDbCondition(ConditionInterface $db_condition) {
$conditions = $db_condition
->conditions();
$filter = $this->query
->createConditionGroup($conditions['#conjunction']);
unset($conditions['#conjunction']);
foreach ($conditions as $condition) {
if ($condition['operator'] === NULL) {
$this
->abort('Trying to include a raw SQL condition in a Search API query.');
return NULL;
}
if ($condition['field'] instanceof ConditionInterface) {
$nested_filter = $this
->transformDbCondition($condition['field']);
if ($nested_filter) {
$filter
->addConditionGroup($nested_filter);
}
else {
return NULL;
}
}
else {
$filter
->addCondition($this
->sanitizeFieldId($condition['field']), $condition['value'], $this
->sanitizeOperator($condition['operator']));
}
}
return $filter;
}