Drupal investigation

migrate_plus.install 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for migrate_plus.
  5. */
  6. /**
  7. * Converts 8.0.x core migration entities to 8.1.x migrate_plus entities.
  8. */
  9. function migrate_plus_update_8100() {
  10. // We cannot use the configration entity system directly, because the entity
  11. // type migrate.migration.* no longer exists - we must directly manipulate
  12. // the config table.
  13. $database = \Drupal::database();
  14. $migration_config = $database->select('config', 'c')
  15. ->fields('c', ['name', 'data'])
  16. ->condition('name', 'migrate.migration.%', 'LIKE')
  17. ->execute();
  18. foreach ($migration_config as $migration) {
  19. $data = unserialize($migration->data);
  20. if (isset($data['third_party_settings']['migrate_plus']['migration_group'])) {
  21. $data['migration_group'] = $data['third_party_settings']['migrate_plus']['migration_group'];
  22. unset($data['third_party_settings']['migrate_plus']);
  23. if (empty($data['third_party_settings'])) {
  24. unset($data['third_party_settings']);
  25. }
  26. $new_name = str_replace('migrate.migration.', 'migrate_plus.migration.', $migration->name);
  27. $database->update('config')
  28. ->fields([
  29. 'name' => $new_name,
  30. 'data' => serialize($data),
  31. ])
  32. ->condition('name', $migration->name)
  33. ->execute();
  34. }
  35. }
  36. }