protected function SqlContentEntityStorageSchema::getFieldForeignKeys in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::getFieldForeignKeys()
Gets field foreign keys.
Parameters
string $field_name: The name of the field.
array $field_schema: The schema of the field.
string[] $column_mapping: A mapping of field column names to database column names.
Return value
array The schema definition for the foreign keys.
1 call to SqlContentEntityStorageSchema::getFieldForeignKeys()
- SqlContentEntityStorageSchema::getSharedTableFieldSchema in core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php - Gets the schema for a single field definition.
File
- core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php, line 749 - Contains \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema.
Class
- SqlContentEntityStorageSchema
- Defines a schema handler that supports revisionable, translatable entities.
Namespace
Drupal\Core\Entity\SqlCode
protected function getFieldForeignKeys($field_name, array $field_schema, array $column_mapping) {
$foreign_keys = array();
foreach ($field_schema['foreign keys'] as $specifier => $specification) {
// To avoid clashes with entity-level foreign keys we use
// "{$entity_type_id}_field__" as a prefix instead of just
// "{$entity_type_id}__". We additionally namespace the specifier by the
// field name to avoid clashes when multiple fields of the same type are
// added to an entity type.
$entity_type_id = $this->entityType
->id();
$real_specifier = "{$entity_type_id}_field__{$field_name}__{$specifier}";
$foreign_keys[$real_specifier]['table'] = $specification['table'];
foreach ($specification['columns'] as $column => $referenced) {
$foreign_keys[$real_specifier]['columns'][$column_mapping[$column]] = $referenced;
}
}
return $foreign_keys;
}