function SqlContentEntityStorageSchema::initializeDataTable

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::initializeDataTable()
  2. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::initializeDataTable()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::initializeDataTable()

Initializes common information for a data table.

Parameters

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

Return value

array A partial schema array for the data table.

1 call to SqlContentEntityStorageSchema::initializeDataTable()
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 1371

Class

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

Namespace

Drupal\Core\Entity\Sql

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.