You are here

public function JobItemState::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 InOperator::query

File

src/Plugin/views/filter/JobItemState.php, line 63

Class

JobItemState
Filter based on job item state.

Namespace

Drupal\tmgmt\Plugin\views\filter

Code

public function query() {
  $key = reset($this->value);
  $field = $this->field;
  $table = $this->table;
  switch ($key) {
    case 'open_job_items':
      $this->query
        ->addWhere($this->options['group'], "{$table}.{$field}", [
        0,
        1,
        2,
      ], 'IN');
      break;
    default:
      $state_definitions = JobItem::getStateDefinitions();
      if ($state_definitions[$key]['type'] == 'translator_state') {
        $field = 'translator_state';
      }
      $this->query
        ->addWhere($this->options['group'], "{$table}.{$field}", $key, '=');
      break;
  }
}