protected function SearchBuilder::setFiltersConjunction in Elasticsearch Connector 8.2
Same name and namespace in other branches
- 8.7 src/ElasticSearch/Parameters/Builder/SearchBuilder.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Builder\SearchBuilder::setFiltersConjunction()
- 8.5 src/ElasticSearch/Parameters/Builder/SearchBuilder.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Builder\SearchBuilder::setFiltersConjunction()
- 8.6 src/ElasticSearch/Parameters/Builder/SearchBuilder.php \Drupal\elasticsearch_connector\ElasticSearch\Parameters\Builder\SearchBuilder::setFiltersConjunction()
Helper function that set filters conjunction.
Parameters
array $filters:
string $conjunction:
Return value
array|null
Throws
\Exception
1 call to SearchBuilder::setFiltersConjunction()
- SearchBuilder::getQueryFilters in src/
ElasticSearch/ Parameters/ Builder/ SearchBuilder.php - Recursively parse Search API condition group.
File
- src/
ElasticSearch/ Parameters/ Builder/ SearchBuilder.php, line 390
Class
- SearchBuilder
- Class SearchBuilder.
Namespace
Drupal\elasticsearch_connector\ElasticSearch\Parameters\BuilderCode
protected function setFiltersConjunction(array &$filters, $conjunction) {
if (count($filters) > 1) {
if ($conjunction === 'OR') {
$filters = [
[
'or' => $filters,
],
];
}
elseif ($conjunction === 'AND') {
$filters = [
[
'and' => $filters,
],
];
}
else {
throw new \Exception(t('Undefined conjunction :conjunction! Available values are :avail_conjunction! Incorrect filter criteria is using for searching!', [
':conjunction!' => $conjunction,
':avail_conjunction' => $conjunction,
]));
}
}
return $filters;
}