protected function SqlContentEntityStorageSchema::initializeRevisionTable

protected SqlContentEntityStorageSchema::initializeRevisionTable(ContentEntityTypeInterface $entity_type)

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.

File

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

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 = array(
    'description' => "The revision table for $entity_type_id entities.",
    'primary key' => array($revision_key),
    'indexes' => array(),
    'foreign keys' => array(
      $entity_type_id . '__revisioned' => array(
        'table' => $this->storage->getBaseTable(),
        'columns' => array($id_key => $id_key),
      ),
    ),
  );

  $schema['indexes'][$this->getEntityIndexName($entity_type, $id_key)] = array($id_key);

  $this->addTableDefaults($schema);

  return $schema;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::initializeRevisionTable/8.1.x