You are here

public function MultiversionMigration::applyNewStorage in Multiversion 8

Converts the entity storage to revisionable for the given entity type IDs.

Parameters

array $entity_type_ids: An array of entity types for which to convert the storage.

Return value

$this

Overrides MultiversionMigrationInterface::applyNewStorage

File

src/MultiversionMigration.php, line 140

Class

MultiversionMigration

Namespace

Drupal\multiversion

Code

public function applyNewStorage(array $entity_type_ids) {
  if (version_compare(\Drupal::VERSION, '8.7', '<')) {

    // The first call is for making entity types revisionable, the second call
    // is for adding required fields.
    \Drupal::entityDefinitionUpdateManager()
      ->applyUpdates();
    \Drupal::entityDefinitionUpdateManager()
      ->applyUpdates();
  }
  else {
    foreach ($entity_type_ids as $entity_type_id) {
      $entity_type = \Drupal::entityTypeManager()
        ->getDefinition($entity_type_id);
      $field_storage_definitions = \Drupal::service('entity_field.manager')
        ->getFieldStorageDefinitions($entity_type_id);
      \Drupal::entityDefinitionUpdateManager()
        ->updateFieldableEntityType($entity_type, $field_storage_definitions);
    }
  }
  return $this;
}