diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index edaff20..6d16a22 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -6,6 +6,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Url; @@ -76,6 +77,13 @@ class MigrateUpgradeForm extends ConfirmFormBase { protected $moduleHandler; /** + * The messenger service. + * + * @var \Drupal\Core\Messenger\MessengerInterface + */ + protected $messenger; + + /** * List of extensions that do not need an upgrade path. * * This property is an array where the keys are the major Drupal core version @@ -187,13 +195,14 @@ class MigrateUpgradeForm extends ConfirmFormBase { * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ - public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrateFieldPluginManagerInterface $field_plugin_manager, ModuleHandlerInterface $module_handler) { + public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrateFieldPluginManagerInterface $field_plugin_manager, ModuleHandlerInterface $module_handler, MessengerInterface $messenger) { $this->state = $state; $this->dateFormatter = $date_formatter; $this->renderer = $renderer; $this->pluginManager = $plugin_manager; $this->fieldPluginManager = $field_plugin_manager; $this->moduleHandler = $module_handler; + $this->messenger = $messenger; } /** @@ -206,7 +215,8 @@ public static function create(ContainerInterface $container) { $container->get('renderer'), $container->get('plugin.manager.migration'), $container->get('plugin.manager.migrate.field'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('messenger') ); } @@ -236,7 +246,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { return $this->buildConfirmForm($form, $form_state); default: - drupal_set_message($this->t('Unrecognized form step @step', ['@step' => $this->step]), 'error'); + $this->messenger->addError($this->t('Unrecognized form step @step', ['@step' => $this->step])); return []; } } @@ -608,7 +618,7 @@ public function buildIdConflictForm(array &$form, FormStateInterface $form_state return $this->buildForm($form, $form_state); } - drupal_set_message($this->t('WARNING: Content may be overwritten on your new site.'), 'warning'); + $this->messenger->addWarning($this->t('WARNING: Content may be overwritten on your new site.')); $form = parent::buildForm($form, $form_state); $form['actions']['submit']['#submit'] = ['::submitConfirmIdConflictForm']; @@ -749,11 +759,11 @@ public function buildConfirmForm(array $form, FormStateInterface $form_state) { $migration_id = $migration->getPluginId(); $source_module = $migration->getSourcePlugin()->getSourceModule(); if (!$source_module) { - drupal_set_message($this->t('Source module not found for @migration_id.', ['@migration_id' => $migration_id]), 'error'); + $this->messenger->addError($this->t('Source module not found for @migration_id.', ['@migration_id' => $migration_id])); } $destination_module = $migration->getDestinationPlugin()->getDestinationModule(); if (!$destination_module) { - drupal_set_message($this->t('Destination module not found for @migration_id.', ['@migration_id' => $migration_id]), 'error'); + $this->messenger->addError($this->t('Destination module not found for @migration_id.', ['@migration_id' => $migration_id])); } if ($source_module && $destination_module) {