You are here

public function TranslationLanguageJoin::buildJoin in Translation Views 8

Builds the SQL for the join this object represents.

When possible, try to use table alias instead of table names.

Parameters

$select_query: An select query object.

$table: The base table to join.

\Drupal\views\Plugin\views\query\QueryPluginBase $view_query: The source views query.

Overrides JoinPluginBase::buildJoin

File

src/Plugin/views/join/TranslationLanguageJoin.php, line 50

Class

TranslationLanguageJoin
Special join to show all translatable langcodes per one row.

Namespace

Drupal\translation_views\Plugin\views\join

Code

public function buildJoin($select_query, $table, $view_query) {
  $query = $this->database
    ->select($this->table, 'efd');
  $query
    ->fields('efd', [
    $this->eid,
  ]);
  if (!empty($this->configuration['langcodes_as_count'])) {
    $query
      ->addExpression("COUNT(efd.langcode)", 'count_langs');
    if (isset($this->configuration['include_original_language']) && $this->configuration['include_original_language'] == FALSE) {
      $query
        ->where('efd.default_langcode != 1');
    }
  }
  else {
    $query
      ->addExpression("GROUP_CONCAT(efd.langcode separator ',')", 'langs');
  }
  $query
    ->groupBy('efd.' . $this->eid);
  $this->configuration['table formula'] = $query;
  parent::buildJoin($select_query, $table, $view_query);
}