function 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 1203 
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 = [];
  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;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
