Tables::ensureFieldTable
protected function Tables::ensureFieldTable
protected Tables::ensureFieldTable($index_prefix, &$field, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta)
Join field table if necessary.
Parameters
$field_name: Name of the field.
Return value
string
Throws
\Drupal\Core\Entity\Query\QueryException
File
- core/lib/Drupal/Core/Entity/Query/Sql/Tables.php, line 315
Class
- Tables
- Adds tables and fields to the SQL entity query.
Namespace
Drupal\Core\Entity\Query\SqlCode
protected function ensureFieldTable($index_prefix, &$field, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta) { $field_name = $field->getName(); if (!isset($this->fieldTables[$index_prefix . $field_name])) { $entity_type_id = $this->sqlQuery->getMetaData('entity_type'); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = $this->entityManager->getStorage($entity_type_id)->getTableMapping(); $table = !$this->sqlQuery->getMetaData('all_revisions') ? $table_mapping->getDedicatedDataTableName($field) : $table_mapping->getDedicatedRevisionTableName($field); if ($field->getCardinality() != 1) { $this->sqlQuery->addMetaData('simple_query', FALSE); } $this->fieldTables[$index_prefix . $field_name] = $this->addJoin($type, $table, "%alias.$field_id_field = $base_table.$entity_id_field", $langcode, $delta); } return $this->fieldTables[$index_prefix . $field_name]; }
© 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::ensureFieldTable/8.1.x