public function SearchApiLanguage::query in Search API 8
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 LanguageFilter::query
File
- src/
Plugin/ views/ filter/ SearchApiLanguage.php, line 21
Class
- SearchApiLanguage
- Defines a filter for filtering on the language of items.
Namespace
Drupal\search_api\Plugin\views\filterCode
public function query() {
$substitutions = static::queryLanguageSubstitutions();
foreach ($this->value as $i => $value) {
if (isset($substitutions[$value])) {
$this->value[$i] = $substitutions[$value];
}
}
// Only set the languages using $query->setLanguages() if the condition
// would be placed directly on the query, as an AND condition.
$query = $this
->getQuery();
$direct_language_condition = $this->realField === 'search_api_language' && $this->operator == 'in' && $query
->getGroupType($this->options['group']) && $query
->getGroupOperator() == 'AND';
if ($direct_language_condition) {
$query
->setLanguages($this->value);
}
else {
parent::query();
}
}