You are here

protected function SqlContentEntityStorageSchema::addSharedTableFieldForeignKey in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addSharedTableFieldForeignKey()

Adds a foreign key for the specified field to the given schema definition.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The storage definition of the field to which to add a foreign key.

array $schema: A reference to the schema array to be updated.

string $foreign_table: The foreign table.

string $foreign_column: The foreign column.

3 calls to SqlContentEntityStorageSchema::addSharedTableFieldForeignKey()
CommentStorageSchema::getSharedTableFieldSchema in core/modules/comment/src/CommentStorageSchema.php
Gets the schema for a single field definition.
ItemStorageSchema::getSharedTableFieldSchema in core/modules/aggregator/src/ItemStorageSchema.php
Gets the schema for a single field definition.
NodeStorageSchema::getSharedTableFieldSchema in core/modules/node/src/NodeStorageSchema.php
Gets the schema for a single field definition.

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 2251

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

protected function addSharedTableFieldForeignKey(FieldStorageDefinitionInterface $storage_definition, &$schema, $foreign_table, $foreign_column) {
  $name = $storage_definition
    ->getName();
  $real_key = $this
    ->getFieldSchemaIdentifierName($storage_definition
    ->getTargetEntityTypeId(), $name);
  $schema['foreign keys'][$real_key] = [
    'table' => $foreign_table,
    'columns' => [
      $name => $foreign_column,
    ],
  ];
}