function SqlContentEntityStorage::initTableLayout

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

Initializes table name variables.

3 calls to SqlContentEntityStorage::initTableLayout()
SqlContentEntityStorage::onEntityTypeUpdate in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
SqlContentEntityStorage::setEntityType in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Updates the wrapped entity type definition.
SqlContentEntityStorage::__construct in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Constructs a SqlContentEntityStorage object.

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 195

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

protected function initTableLayout() {
    // Reset table field values to ensure changes in the entity type definition
    // are correctly reflected in the table layout.
    $this->tableMapping = NULL;
    $this->revisionKey = NULL;
    $this->revisionTable = NULL;
    $this->dataTable = NULL;
    $this->revisionDataTable = NULL;
    $table_mapping = $this->getTableMapping();
    $this->baseTable = $table_mapping->getBaseTable();
    $revisionable = $this->entityType
        ->isRevisionable();
    if ($revisionable) {
        $this->revisionKey = $this->entityType
            ->getKey('revision') ?: 'revision_id';
        $this->revisionTable = $table_mapping->getRevisionTable();
    }
    $translatable = $this->entityType
        ->isTranslatable();
    if ($translatable) {
        $this->dataTable = $table_mapping->getDataTable();
        $this->langcodeKey = $this->entityType
            ->getKey('langcode');
        $this->defaultLangcodeKey = $this->entityType
            ->getKey('default_langcode');
    }
    if ($revisionable && $translatable) {
        $this->revisionDataTable = $table_mapping->getRevisionDataTable();
    }
}

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