You are here

protected function Tables::addJoin in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::addJoin()
2 calls to Tables::addJoin()
Tables::ensureEntityTable in core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
Join entity table if necessary and return the alias for it.
Tables::ensureFieldTable in core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
Join field table if necessary.

File

core/lib/Drupal/Core/Entity/Query/Sql/Tables.php, line 278
Contains \Drupal\Core\Entity\Query\Sql\Tables.

Class

Tables
Adds tables and fields to the SQL entity query.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function addJoin($type, $table, $join_condition, $langcode) {
  $arguments = array();
  if ($langcode) {
    $entity_type_id = $this->sqlQuery
      ->getMetaData('entity_type');
    $entity_type = $this->entityManager
      ->getDefinition($entity_type_id);

    // Only the data table follows the entity language key, dedicated field
    // tables have an hard-coded 'langcode' column.
    $langcode_key = $entity_type
      ->getDataTable() == $table ? $entity_type
      ->getKey('langcode') : 'langcode';
    $placeholder = ':langcode' . $this->sqlQuery
      ->nextPlaceholder();
    $join_condition .= ' AND %alias.' . $langcode_key . ' = ' . $placeholder;
    $arguments[$placeholder] = $langcode;
  }
  return $this->sqlQuery
    ->addJoin($type, $table, NULL, $join_condition, $arguments);
}