SqlContentEntityStorageSchema::initializeDataTable

protected SqlContentEntityStorageSchema::initializeDataTable(ContentEntityTypeInterface $entity_type)

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.

File

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

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 = array(
    'description' => "The data table for $entity_type_id entities.",
    'primary key' => array($id_key, $entity_type->getKey('langcode')),
    'indexes' => array(
      $entity_type_id . '__id__default_langcode__langcode' => array($id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')),
    ),
    'foreign keys' => array(
      $entity_type_id => array(
        'table' => $this->storage->getBaseTable(),
        'columns' => array($id_key => $id_key),
      ),
    ),
  );

  if ($entity_type->hasKey('revision')) {
    $key = $entity_type->getKey('revision');
    $schema['indexes'][$this->getEntityIndexName($entity_type, $key)] = array($key);
  }

  $this->addTableDefaults($schema);

  return $schema;
}
doc_Drupal
2016-10-29 09:43:41
Comments
Leave a Comment

Please login to continue.