diff --git a/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php b/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php index 314eeff6b9..fc1ac84c1d 100644 --- a/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php @@ -2,6 +2,8 @@ namespace Drupal\migrate_drupal_ui\Form; +use Drupal\Core\Extension\Exception\UnknownExtensionException; +use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\TempStore\PrivateTempStoreFactory; @@ -65,6 +67,20 @@ class ReviewForm extends MigrateUpgradeFormBase { */ protected $migrationState; + /** + * Module handler. + * + * @var \Drupal\Core\Extension\ModuleHandler + */ + protected $moduleHandler; + + /** + * Source system data. + * + * @var array + */ + protected $systemData; + /** * ReviewForm constructor. * @@ -78,13 +94,16 @@ class ReviewForm extends MigrateUpgradeFormBase { * The private tempstore factory. * @param \Drupal\migrate_drupal\MigrationState $migrationState * Migration state service. + * @param \Drupal\Core\Extension\ModuleHandler $module_handler + * Module handler service. */ - public function __construct(StateInterface $state, MigrationPluginManagerInterface $migration_plugin_manager, MigrateFieldPluginManagerInterface $field_plugin_manager, PrivateTempStoreFactory $tempstore_private, MigrationState $migrationState) { + public function __construct(StateInterface $state, MigrationPluginManagerInterface $migration_plugin_manager, MigrateFieldPluginManagerInterface $field_plugin_manager, PrivateTempStoreFactory $tempstore_private, MigrationState $migrationState, ModuleHandler $module_handler) { parent::__construct($tempstore_private); $this->state = $state; $this->pluginManager = $migration_plugin_manager; $this->fieldPluginManager = $field_plugin_manager; $this->migrationState = $migrationState; + $this->moduleHandler = $module_handler; } /** @@ -96,7 +115,8 @@ public static function create(ContainerInterface $container) { $container->get('plugin.manager.migration'), $container->get('plugin.manager.migrate.field'), $container->get('tempstore.private'), - $container->get('migrate_drupal.migration_state') + $container->get('migrate_drupal.migration_state'), + $container->get('module_handler') ); } @@ -115,10 +135,10 @@ public function buildForm(array $form, FormStateInterface $form_state) { $version = $this->store->get('version'); $this->migrations = $this->store->get('migrations'); // Fetch the source system data at the first opportunity. - $system_data = $this->store->get('system_data'); + $this->systemData = $this->store->get('system_data'); // If data is missing or this is the wrong step, start over. - if (!$version || !$this->migrations || !$system_data || + if (!$version || !$this->migrations || !$this->systemData || ($this->store->get('step') != 'review')) { return $this->restartUpgradeForm(); } @@ -129,7 +149,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $migrations = $this->pluginManager->createInstances(array_keys($this->store->get('migrations'))); // Get the upgrade states for the source modules. - $display = $this->migrationState->getUpgradeStates($version, $system_data, $migrations); + $display = $this->migrationState->getUpgradeStates($version, $this->systemData, $migrations); // Missing migrations. $missing_module_list = [ @@ -150,7 +170,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { $missing_count = 0; if (isset($display[MigrationState::NOT_FINISHED])) { - foreach ($display[MigrationState::NOT_FINISHED] as $source_module => $destination_modules) { + $module_names = $this->sortByName($display[MigrationState::NOT_FINISHED]); + foreach ($module_names as $source_module => $destination_modules) { + $data = unserialize($this->systemData['module'][$source_module]['info']); $missing_count++; // Get the migration status for this $source_module, if a module of the // same name exists on the destination site. @@ -164,6 +186,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { 'upgrade-analysis-report__status-icon', 'upgrade-analysis-report__status-icon--error', ], + 'title' => $data['name'], ], ], 'destination_module' => [ @@ -191,18 +214,21 @@ public function buildForm(array $form, FormStateInterface $form_state) { $available_count = 0; if (isset($display[MigrationState::FINISHED])) { - foreach ($display[MigrationState::FINISHED] as $source_module => $destination_modules) { + $module_names = $this->sortByName($display[MigrationState::FINISHED]); + foreach ($module_names as $source_module => $destination_modules) { + $data = unserialize($this->systemData['module'][$source_module]['info']); $available_count++; $available_module_list['module_list'][] = [ 'source_module' => [ '#type' => 'html_tag', '#tag' => 'span', - '#value' => $source_module, + '#value' => $source_module , '#attributes' => [ 'class' => [ 'upgrade-analysis-report__status-icon', 'upgrade-analysis-report__status-icon--checked', ], + 'title' => $data['name'], ], ], 'destination_module' => [ @@ -278,4 +304,43 @@ public function getConfirmText() { return $this->t('Perform upgrade'); } + /** + * Converts destination module machine names to the module name. + * + * @param array $migration_state + * A migration state array using module machine names. + * + * @return array + * An array of module names, where the key is the source module name and the + * value is a comma separated list of destination modules. + */ + protected function sortByName(array $migration_state) { + $module_names = []; + foreach ($migration_state as $source_module => $destination_modules) { + // Get the names of all the destination modules. + $destination_module_names = []; + if (!empty($destination_modules)) { + $destination_modules = explode(', ', $destination_modules); + foreach ($destination_modules as $destination_module) { + if ($destination_module === 'core') { + $destination_module_names[] = 'Core'; + } + else { + try { + $destination_module_names[] = $this->moduleHandler->getName($destination_module); + } + catch (UnknownExtensionException $e) { + $destination_module_names[] = $destination_module; + } + } + } + } + sort($destination_module_names); + $destination_module_names = implode(', ', $destination_module_names); + $module_names[$source_module] = $destination_module_names; + } + ksort($module_names); + return $module_names; + } + } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php index b9f11b20e3..bafbed20c2 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php @@ -72,6 +72,7 @@ public function testMigrateUpgradeReviewPage() { // does not need any. Test with a module that is was in both Drupal 6 and // Drupal 7 core. $module = 'help'; + $module_name = 'Help'; $query = $this->sourceDatabase->delete('system'); $query->condition('type', 'module'); $query->condition('name', $module); @@ -86,7 +87,7 @@ public function testMigrateUpgradeReviewPage() { // Test the upgrade paths. First remove the module from the available paths // list. $available_paths = $this->getAvailablePaths(); - $available_paths = array_diff($available_paths, [$module]); + $available_paths = array_diff($available_paths, [$module_name]); $missing_paths = $this->getMissingPaths(); $this->assertUpgradePaths($session, $available_paths, $missing_paths); } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php index b5fdc0239b..4d69a5f6e2 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php @@ -72,8 +72,8 @@ protected function getAvailablePaths() { 'ctools_custom_content', 'dashboard', 'date', - 'date_api', 'date_all_day', + 'date_api', 'date_context', 'date_migrate', 'date_popup', @@ -168,9 +168,9 @@ protected function getMissingPaths() { 'i18n_translation', 'i18n_user', 'i18n_variable', + 'migrate_status_active_test', 'node', 'picture', - 'migrate_status_active_test', 'variable', 'variable_admin', 'variable_realm',