You are here

public function MigrateUpgradeForm::buildOverviewForm in Migrate Upgrade 8

Builds the form presenting an overview of the migration process.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

1 call to MigrateUpgradeForm::buildOverviewForm()
MigrateUpgradeForm::buildForm in src/Form/MigrateUpgradeForm.php
Form constructor.

File

src/Form/MigrateUpgradeForm.php, line 705
Contains \Drupal\migrate_upgrade\Form\MigrateUpgradeForm.

Class

MigrateUpgradeForm
Defines a multi-step form for performing direct site upgrades.

Namespace

Drupal\migrate_upgrade\Form

Code

public function buildOverviewForm(array $form, FormStateInterface $form_state) {
  $form['#title'] = $this
    ->t('Drupal Upgrade');
  if ($date_performed = $this->state
    ->get('migrate_upgrade.performed')) {
    $form['upgrade_option_item'] = [
      '#type' => 'item',
      '#prefix' => $this
        ->t('<p>An upgrade has already been performed on this site.</p>'),
      '#description' => $this
        ->t('<p>Last upgrade: @date</p>', [
        '@date' => $this->dateFormatter
          ->format($date_performed),
      ]),
    ];
    $form['upgrade_option'] = array(
      '#type' => 'radios',
      '#title' => $this
        ->t('You have two options:'),
      '#default_value' => static::MIGRATE_UPGRADE_INCREMENTAL,
      '#options' => [
        static::MIGRATE_UPGRADE_INCREMENTAL => $this
          ->t('<strong>Rerun</strong>: Import additional configuration and content that was not available when running the upgrade previously.'),
        static::MIGRATE_UPGRADE_ROLLBACK => $this
          ->t('<strong>Rollback</strong>: Remove content and configuration entities (such as fields and node types). Default values of other configuration will not be reverted (such as site name).'),
      ],
    );
    $validate = [
      '::validateCredentialForm',
    ];
  }
  else {
    $form['info_header'] = [
      '#markup' => '<p>' . $this
        ->t('Upgrade a Drupal site by importing it into a clean and empty new install of Drupal 8. You will lose any existing configuration once you import your site into it. See the <a href=":url">upgrading handbook</a> for more detailed information.', [
        ':url' => 'https://www.drupal.org/upgrade/migrate',
      ]),
    ];
    $info[] = $this
      ->t('<strong>Back up the database for this site</strong>. Upgrade will change the database for this site.');
    $info[] = $this
      ->t('Make sure that the host this site is on has access to the database for your previous site.');
    $info[] = $this
      ->t('If your previous site has private files to be migrated, a copy of your files directory must be accessible on the host this site is on.');
    $info[] = $this
      ->t('In general, enable all modules on this site that are enabled on the previous site. For example, if you have used the book module on the previous site then you must enable the book module on this site for that data to be available on this site.');
    $info[] = $this
      ->t('Put this site into <a href=":url">maintenance mode</a>.', [
      ':url' => Url::fromRoute('system.site_maintenance_mode')
        ->toString(TRUE)
        ->getGeneratedUrl(),
    ]);
    $form['info'] = [
      '#theme' => 'item_list',
      '#list_type' => 'ol',
      '#items' => $info,
    ];
    $form['info_footer'] = [
      '#markup' => '<p>' . $this
        ->t('This upgrade can take a long time. It is better to import a local copy of your site instead of directly importing from your live site.'),
    ];
    $validate = [];
  }
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['save'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Continue'),
    '#button_type' => 'primary',
    '#validate' => $validate,
    '#submit' => [
      '::submitOverviewForm',
    ],
  ];
  return $form;
}