function SqlContentEntityStorageSchema::hasSharedTableNameChanges

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

Detects whether any table name got renamed in an entity type update.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The new entity type.

\Drupal\Core\Entity\EntityTypeInterface $original: The origin entity type.

Return value

bool Returns TRUE if there have been changes.

1 call to SqlContentEntityStorageSchema::hasSharedTableNameChanges()
SqlContentEntityStorageSchema::hasSharedTableStructureChange in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Detects whether there is a change in the shared table structure.

File

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

Class

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

Namespace

Drupal\Core\Entity\Sql

Code

protected function hasSharedTableNameChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
    $base_table = $this->database
        ->schema()
        ->tableExists($entity_type->getBaseTable());
    $data_table = $this->database
        ->schema()
        ->tableExists($entity_type->getDataTable());
    $revision_table = $this->database
        ->schema()
        ->tableExists($entity_type->getRevisionTable());
    $revision_data_table = $this->database
        ->schema()
        ->tableExists($entity_type->getRevisionDataTable());
    // We first check if the new table already exists because the storage might
    // have created it even though it wasn't specified in the entity type
    // definition.
    return !$base_table && $entity_type->getBaseTable() != $original->getBaseTable() || !$data_table && $entity_type->getDataTable() != $original->getDataTable() || !$revision_table && $entity_type->getRevisionTable() != $original->getRevisionTable() || !$revision_data_table && $entity_type->getRevisionDataTable() != $original->getRevisionDataTable();
}

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