public function AllowedLanguages::query in Allowed Languages 8
Same name and namespace in other branches
- 2.x src/Plugin/views/filter/AllowedLanguages.php \Drupal\allowed_languages\Plugin\views\filter\AllowedLanguages::query()
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 FilterPluginBase::query
File
- src/
Plugin/ views/ filter/ AllowedLanguages.php, line 31
Class
- AllowedLanguages
- Filter content by the current users allowed languages.
Namespace
Drupal\allowed_languages\Plugin\views\filterCode
public function query() {
$user = allowed_languages_get_current_user();
$allowed_languages = allowed_languages_get_allowed_languages_for_user($user);
if ($allowed_languages) {
$this
->ensureMyTable();
$field = "{$this->tableAlias}.{$this->realField}";
$value = array_values($allowed_languages);
$this->query
->addWhere($this->options['group'], $field, $value, 'IN');
}
}