You are here

protected function SqlContentEntityStorageSchema::initializeRevisionTable in Drupal 9

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

Initializes common information for a revision table.

Parameters

\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type: The entity type.

Return value

array A partial schema array for the revision table.

1 call to SqlContentEntityStorageSchema::initializeRevisionTable()
SqlContentEntityStorageSchema::getEntitySchema in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Gets the entity schema for the specified entity type.

File

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

Class

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

Namespace

Drupal\Core\Entity\Sql

Code

protected function initializeRevisionTable(ContentEntityTypeInterface $entity_type) {
  $entity_type_id = $entity_type
    ->id();
  $id_key = $entity_type
    ->getKey('id');
  $revision_key = $entity_type
    ->getKey('revision');
  $schema = [
    'description' => "The revision table for {$entity_type_id} entities.",
    'primary key' => [
      $revision_key,
    ],
    'indexes' => [],
    'foreign keys' => [
      $entity_type_id . '__revisioned' => [
        'table' => $this->storage
          ->getBaseTable(),
        'columns' => [
          $id_key => $id_key,
        ],
      ],
    ],
  ];
  $schema['indexes'][$this
    ->getEntityIndexName($entity_type, $id_key)] = [
    $id_key,
  ];
  $this
    ->addTableDefaults($schema);
  return $schema;
}