diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/MigrateDrupalRunBatch.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/MigrateDrupalRunBatch.php index 7578161..9c1ecf7 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/MigrateDrupalRunBatch.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/MigrateDrupalRunBatch.php @@ -23,17 +23,49 @@ class MigrateDrupalRunBatch { * The batch context. */ public static function run($initial_ids, $db_spec, &$context) { - Database::addConnectionInfo('migrate', 'default', $db_spec); +// Database::addConnectionInfo('migrate', 'default', $db_spec); if (!isset($context['sandbox']['migration_ids'])) { $context['sandbox']['max'] = count($initial_ids); $context['sandbox']['migration_ids'] = $initial_ids; } +// dvm($context['sandbox']['migration_ids']); $migration_id = reset($context['sandbox']['migration_ids']); $migration = entity_load('migration', $migration_id); - // @TODO: if there are no source IDs then remove php.ini time limit. - // @TODO: move time limit back into MigrateExecutable so we can set it here. - $executable = new MigrateExecutable($migration, new MigrateMessage()); - if ($executable->import() == MigrationInterface::RESULT_COMPLETED) { + if ($migration) { + // @TODO: if there are no source IDs then remove php.ini time limit. + // @TODO: move time limit back into MigrateExecutable so we can set it here. + $executable = new MigrateExecutable($migration, new MigrateMessage()); + $migration_status = $executable->import(); + switch ($migration_status) { + case MigrationInterface::RESULT_COMPLETED: + $context['message'] = t('Imported @migration', + array('@migration' => $migration_id)); + break; + case MigrationInterface::RESULT_INCOMPLETE: + $context['message'] = t('Importing @migration', + array('@migration' => $migration_id)); + break; + case MigrationInterface::RESULT_STOPPED: + $context['message'] = t('Import stopped by request'); + break; + case MigrationInterface::RESULT_FAILED: + $context['message'] = t('Import of @migration failed', + array('@migration' => $migration_id)); + break; + case MigrationInterface::RESULT_SKIPPED: + $context['message'] = t('Import of @migration skipped due to unfulfilled dependencies', + array('@migration' => $migration_id)); + break; + case MigrationInterface::RESULT_DISABLED: + // Skip silently if disabled. + break; + } + // Unless we're continuing on with this migration, take it off the list. + if ($executable->import() != MigrationInterface::RESULT_INCOMPLETE) { + array_shift($context['sandbox']['migration_ids']); + } + } + else { array_shift($context['sandbox']['migration_ids']); } $context['finished'] = 1 - count($context['sandbox']['migration_ids']) / $context['sandbox']['max']; diff --git a/core/modules/migrate_drupal/migrate_drupal.module b/core/modules/migrate_drupal/migrate_drupal.module index 5a71396..12ff47c 100644 --- a/core/modules/migrate_drupal/migrate_drupal.module +++ b/core/modules/migrate_drupal/migrate_drupal.module @@ -10,3 +10,33 @@ function migrate_drupal_entity_type_alter(array &$entity_types) { ->setClass('Drupal\migrate_drupal\Entity\Migration') ->setControllerClass('storage', 'Drupal\migrate_drupal\MigrationStorage'); } + +/** + * Implements hook_menu(). + */ +function migrate_drupal_menu() { + $items['admin/config/system/upgrade'] = array( + 'title' => 'Migration', + 'description' => 'Manage automatic site maintenance tasks.', + 'route_name' => 'migrate_drupal.upgrade', + 'weight' => 30, + ); + + return $items; +} + +/** + * Implements hook_menu_link_defaults(). + */ +function migrate_drupal_menu_link_defaults() { + $items['system.admin.config.system.upgrade'] = array( + 'link_title' => 'Migration', + 'parent' => 'system.admin.config.system', + 'description' => 'Migrate configuration and content from your previous Drupal version.', + 'route_name' => 'migrate_drupal.upgrade', + 'menu_name' => 'admin', + 'weight' => 30, + ); + + return $items; + } diff --git a/core/modules/migrate_drupal/migrate_drupal.routing.yml b/core/modules/migrate_drupal/migrate_drupal.routing.yml index a7e8fef..eb24fee 100644 --- a/core/modules/migrate_drupal/migrate_drupal.routing.yml +++ b/core/modules/migrate_drupal/migrate_drupal.routing.yml @@ -5,3 +5,10 @@ migrate_drupal.run: _title: 'Run' requirements: _permission: 'administer site configuration' +migrate_drupal.upgrade: + path: '/admin/config/system/upgrade' + defaults: + _form: '\Drupal\migrate_drupal\Form\MigrateDrupalUpgradeForm' + _title: 'Migration' + requirements: + _permission: 'administer site configuration'