class Tables in Dynamic Entity Reference 8.2
Adds tables and fields to the SQL entity query.
Hierarchy
- class \Drupal\Core\Entity\Query\Sql\Tables implements TablesInterface uses DeprecatedServicePropertyTrait
- class \Drupal\dynamic_entity_reference\Query\Tables
Expanded class hierarchy of Tables
File
- src/
Query/ Tables.php, line 13
Namespace
Drupal\dynamic_entity_reference\QueryView source
class Tables extends BaseTables {
/**
* {@inheritdoc}
*/
protected function addNextBaseTable(EntityType $entity_type, $table, $sql_column, FieldStorageDefinitionInterface $field_storage = NULL) {
// Parent method is overridden in order to choose the correct columns to
// join on (string or int for the id and type for the entity type
// specifier).
$entity_type_id_key = $entity_type
->getKey('id');
$entity_type_id = $entity_type
->id();
$join_condition_type = '';
if ($field_storage && $field_storage
->getType() === 'dynamic_entity_reference' && $entity_type_id_key !== FALSE) {
// DER basefield SQL column are named entity_name__target_id and
// entity_name__target_type where as config field columns are named
// field_name_target_id and field_name_target_type.
$sql_column_type = str_replace('target_id', 'target_type', $sql_column);
if (DynamicEntityReferenceItem::entityHasIntegerId($entity_type_id)) {
$sql_column .= '_int';
}
// Prepare to modify the join with an entity type specifier. This can
// prevent obscure cases where entities of different types (e.g. node vs.
// taxonomy_term) with the same id are returned.
$join_condition_type = " AND [{$table}].[{$sql_column_type}] = '{$entity_type_id}'";
}
$join_condition = "[%alias].[{$entity_type_id_key}] = [{$table}].[{$sql_column}]" . $join_condition_type;
return $this->sqlQuery
->leftJoin($entity_type
->getBaseTable(), NULL, $join_condition);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeprecatedServicePropertyTrait:: |
public | function | Allows to access deprecated/removed properties. | |
Tables:: |
protected | property | List of case sensitive fields. | |
Tables:: |
protected | property | ||
Tables:: |
protected | property | The entity field manager. | |
Tables:: |
protected | property | Entity table array. | |
Tables:: |
protected | property | The entity type manager. | |
Tables:: |
protected | property | Field table array, key is table name, value is alias. | |
Tables:: |
protected | property | ||
Tables:: |
public | function |
Adds a field to a database query. Overrides TablesInterface:: |
1 |
Tables:: |
protected | function | Adds a join to a given table. | 1 |
Tables:: |
protected | function |
Add the next entity base table. Overrides Tables:: |
|
Tables:: |
protected | function | Joins the entity table, if necessary, and returns the alias for it. | |
Tables:: |
protected | function | Join field table if necessary. | |
Tables:: |
protected | function | Gets the schema for the given table. | |
Tables:: |
public | function |
Determines whether the given field is case sensitive. Overrides TablesInterface:: |
|
Tables:: |
public | function | 1 |