You are here

public function TaskEligible::query in Translation Management Tool 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 FilterPluginBase::query

File

translators/tmgmt_local/src/Plugin/views/filter/TaskEligible.php, line 26

Class

TaskEligible
Field handler which shows the link for assign translation task to user.

Namespace

Drupal\tmgmt_local\Plugin\views\filter

Code

public function query() {
  $this
    ->ensureMyTable();
  $source = $this->tableAlias . '.source_language';
  $target = $this->tableAlias . '.target_language';

  // Add a new group for the language abilities, which are a set of source
  // and target language combinations.
  $this->query
    ->setWhereGroup('OR', 'eligible');

  // Return all language abilities for the current user.
  foreach (tmgmt_local_supported_language_pairs(NULL, array(
    \Drupal::currentUser()
      ->id(),
  )) as $key => $ability) {
    $key = str_replace('-', '_', $key);
    $arguments = array(
      ':source_' . $key => $ability['source_language'],
      ':target_' . $key => $ability['target_language'],
    );
    $this->query
      ->addWhereExpression('eligible', "{$source} = :source_{$key} AND {$target} = :target_{$key}", $arguments);
  }
}