You are here

protected function MultiversionStorageSchemaConverter::createTemporaryDefinitions in Multiversion 8.2

1 call to MultiversionStorageSchemaConverter::createTemporaryDefinitions()
MultiversionStorageSchemaConverter::convertToMultiversionable in src/Entity/Storage/Sql/MultiversionStorageSchemaConverter.php

File

src/Entity/Storage/Sql/MultiversionStorageSchemaConverter.php, line 676

Class

MultiversionStorageSchemaConverter

Namespace

Drupal\multiversion\Entity\Storage\Sql

Code

protected function createTemporaryDefinitions(array &$sandbox, array $fields_to_update) {

  // Make sure to get the latest entity type definition from code.
  $this->entityTypeManager
    ->useCaches(FALSE);
  $actual_entity_type = $this->entityTypeManager
    ->getDefinition($this->entityTypeId);
  $temporary_entity_type = clone $actual_entity_type;
  $temporary_entity_type
    ->set('base_table', TemporaryTableMapping::getTempTableName($temporary_entity_type
    ->getBaseTable()));
  $temporary_entity_type
    ->set('revision_table', TemporaryTableMapping::getTempTableName($temporary_entity_type
    ->getRevisionTable()));
  if ($temporary_entity_type
    ->isTranslatable()) {
    $temporary_entity_type
      ->set('data_table', TemporaryTableMapping::getTempTableName($temporary_entity_type
      ->getDataTable()));
    $temporary_entity_type
      ->set('revision_data_table', TemporaryTableMapping::getTempTableName($temporary_entity_type
      ->getRevisionDataTable()));
  }

  /** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */
  $storage = $this->entityTypeManager
    ->getStorage($this->entityTypeId);
  $storage
    ->setTemporary(TRUE);
  $storage
    ->setEntityType($temporary_entity_type);
  $updated_storage_definitions = $this->entityFieldManager
    ->getFieldStorageDefinitions($temporary_entity_type
    ->id());
  $temporary_table_mapping = $storage
    ->getTableMapping($updated_storage_definitions);
  $sandbox['temporary_entity_type'] = $temporary_entity_type;
  $sandbox['temporary_table_mapping'] = $temporary_table_mapping;
  $sandbox['updated_storage_definitions'] = $updated_storage_definitions;
}