protected function MultiversionManager::prepareContentForMigration in Multiversion 8
2 calls to MultiversionManager::prepareContentForMigration()
- MultiversionManager::disableEntityTypes in src/
MultiversionManager.php  - MultiversionManager::enableEntityTypes in src/
MultiversionManager.php  - @todo Ensure nothing breaks if the migration is run twice.
 
File
- src/
MultiversionManager.php, line 511  
Class
Namespace
Drupal\multiversionCode
protected function prepareContentForMigration($entity_types, MultiversionMigrationInterface $migration, $op) {
  $has_data = [];
  // Walk through and verify that the original storage is in good order.
  // Flakey contrib modules or mocked tests where some schemas aren't properly
  // installed should be ignored.
  foreach ($entity_types as $entity_type_id => $entity_type) {
    /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
    $storage = $this->entityTypeManager
      ->getStorage($entity_type_id);
    $has_data[$entity_type_id] = FALSE;
    try {
      if ($storage
        ->hasData()) {
        $has_data[$entity_type_id] = TRUE;
      }
    } catch (\Exception $e) {
      // Don't bother with this entity type any more.
      unset($entity_types[$entity_type_id]);
    }
    if ($has_data[$entity_type_id]) {
      // Migrate content to temporary storage.
      $field_map = $migration
        ->getFieldMap($entity_type, $op, self::TO_TMP);
      $migration
        ->migrateContentToTemp($storage
        ->getEntityType(), $field_map);
    }
  }
  // Empty old storages. Do this just after migrating all entities to
  // temporary storage because deleting some entity types could delete
  // referenced entities (E.g.: deleting poll entities will also delete
  // poll_choice).
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($has_data[$entity_type_id] === TRUE) {
      /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
      $storage = $this->entityTypeManager
        ->getStorage($entity_type_id);
      // Because of the way the Entity API treats entity definition updates we
      // need to ensure each storage is empty before we can apply the new
      // definition.
      $migration
        ->emptyOldStorage($storage);
    }
  }
  return $has_data;
}