class TaskEligible

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

Plugin annotation

@ViewsFilter("tmgmt_local_task_eligible");

Hierarchy

  • class \Drupal\tmgmt_local\Plugin\views\filter\TaskEligible extends \Drupal\views\Plugin\views\filter\FilterPluginBase

Expanded class hierarchy of TaskEligible

File

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

Namespace

Drupal\tmgmt_local\Plugin\views\filter
View source
class TaskEligible extends FilterPluginBase {

  /**
   * Where the $query object will reside.
   *
   * @var \Drupal\views\Plugin\views\query\Sql
   */
  public $query = NULL;

  /**
   * {@inheritdoc}
   */
  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);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TaskEligible::$query public property Where the $query object will reside.
TaskEligible::query public function