protected function Tables::addJoin

protected Tables::addJoin($type, $table, $join_condition, $langcode, $delta = NULL)

File

core/lib/Drupal/Core/Entity/Query/Sql/Tables.php, line 330

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, $delta = NULL) {
  $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;
  }
  if (isset($delta)) {
    $placeholder = ':delta' . $this->sqlQuery->nextPlaceholder();
    $join_condition .= ' AND %alias.delta = ' . $placeholder;
    $arguments[$placeholder] = $delta;
  }
  return $this->sqlQuery->addJoin($type, $table, NULL, $join_condition, $arguments);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Query!Sql!Tables.php/function/Tables::addJoin/8.1.x