SqlContentEntityStorageSchema::addSharedTableFieldForeignKey

protected SqlContentEntityStorageSchema::addSharedTableFieldForeignKey(FieldStorageDefinitionInterface $storage_definition, &$schema, $foreign_table, $foreign_column)

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.

File

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

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] = array(
    'table' => $foreign_table,
    'columns' => array($name => $foreign_column),
  );
}
doc_Drupal
2016-10-29 09:43:34
Comments
Leave a Comment

Please login to continue.