X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate_drupal_ui%2Fsrc%2FForm%2FIncrementalForm.php;fp=web%2Fcore%2Fmodules%2Fmigrate_drupal_ui%2Fsrc%2FForm%2FIncrementalForm.php;h=8090190e1f2a2ea7dccf5e96ba00679c9369a389;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/migrate_drupal_ui/src/Form/IncrementalForm.php b/web/core/modules/migrate_drupal_ui/src/Form/IncrementalForm.php new file mode 100644 index 000000000..8090190e1 --- /dev/null +++ b/web/core/modules/migrate_drupal_ui/src/Form/IncrementalForm.php @@ -0,0 +1,130 @@ +state = $state; + $this->dateFormatter = $date_formatter; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('state'), + $container->get('date.formatter'), + $container->get('tempstore.private') + ); + } + + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'migrate_drupal_ui_incremental_form'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state) { + // Get all the data needed for this form. + $date_performed = $this->state->get('migrate_drupal_ui.performed'); + + // If data is missing or this is the wrong step, start over. + if (!$date_performed || $this->store->get('step') != 'incremental') { + return $this->restartUpgradeForm(); + } + + $form = parent::buildForm($form, $form_state); + $form['#title'] = $this->t('Upgrade'); + + // @todo Add back support for rollbacks. + // https://www.drupal.org/node/2687849 + $form['upgrade_option_item'] = [ + '#type' => 'item', + '#prefix' => $this->t('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal 8. Rollbacks are not yet supported through the user interface. For more information, see the upgrading handbook.', [':url' => 'https://www.drupal.org/upgrade/migrate']), + '#description' => $this->t('Last upgrade: @date', ['@date' => $this->dateFormatter->format($date_performed)]), + ]; + return $form; + } + + /** + * {@inheritdoc} + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + // Retrieve the database driver from state. + $database_state_key = $this->state->get('migrate.fallback_state_key', ''); + if ($database_state_key) { + try { + $database = $this->state->get($database_state_key, [])['database']; + if ($connection = $this->getConnection($database)) { + if ($version = $this->getLegacyDrupalVersion($connection)) { + $this->setupMigrations($database, $form_state); + $valid_legacy_database = TRUE; + } + } + } + catch (DatabaseExceptionWrapper $exception) { + // Hide DB exceptions and forward to the DB credentials form. In that + // form we can more properly display errors and accept new credentials. + } + } + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $this->store->set('step', 'credential'); + $form_state->setRedirect('migrate_drupal_ui.upgrade_credential'); + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return $this->t('Import new configuration and content from old site'); + } + +}