public function TranslationStatusFilter::query in Translation Views 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 BooleanOperator::query
File
- src/
Plugin/ views/ filter/ TranslationStatusFilter.php, line 26
Class
- TranslationStatusFilter
- Provides filtering by translation status.
Namespace
Drupal\translation_views\Plugin\views\filterCode
public function query() {
$table_alias = $this
->ensureMyTable();
$status = $this->value;
if ($status == 0) {
$operation = '=';
}
else {
// Mysql FIND_IN_SET func will return position of element,
// when no element was found then it returns 0,
// so we use "> 0" as condition to filter out untranslated rows.
$operation = '>';
$status = 0;
}
/* @var \Drupal\views\Plugin\views\query\Sql */
$this->query
->addWhereExpression($this->options['group'], "FIND_IN_SET(:langcode, {$table_alias}.langs) {$operation} :status", [
':langcode' => '***TRANSLATION_VIEWS_TARGET_LANG***',
':status' => $status,
]);
}