You are here

protected function CredentialForm::setupMigrations in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal_ui/src/Form/CredentialForm.php \Drupal\migrate_drupal_ui\Form\CredentialForm::setupMigrations()
  2. 9 core/modules/migrate_drupal_ui/src/Form/CredentialForm.php \Drupal\migrate_drupal_ui\Form\CredentialForm::setupMigrations()

Gets and stores information for this migration in temporary store.

Gets all the migrations, converts each to an array and stores it in the form state. The source base path for public and private files is also put into form state.

Parameters

\Drupal\Core\Database\Connection $connection: The database connection used.

string $version: The Drupal version.

array $database: Database array representing the source Drupal database.

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

Throws

\Drupal\Core\TempStore\TempStoreException Thrown when a lock for the backend storage could not be acquired.

1 call to CredentialForm::setupMigrations()
CredentialForm::validateForm in core/modules/migrate_drupal_ui/src/Form/CredentialForm.php
Form validation handler.

File

core/modules/migrate_drupal_ui/src/Form/CredentialForm.php, line 349

Class

CredentialForm
Migrate Upgrade database credential form.

Namespace

Drupal\migrate_drupal_ui\Form

Code

protected function setupMigrations(Connection $connection, $version, array $database, FormStateInterface $form_state) {
  $this
    ->createDatabaseStateSettings($database, $version);
  $migrations = $this
    ->getMigrations('migrate_drupal_' . $version, $version);

  // Get the system data from source database.
  $system_data = $this
    ->getSystemData($connection);

  // Convert the migration object into array
  // so that it can be stored in form storage.
  $migration_array = [];
  foreach ($migrations as $migration) {
    $migration_array[$migration
      ->id()] = $migration
      ->label();
  }

  // Store information in the private store.
  $this->store
    ->set('version', $version);
  $this->store
    ->set('migrations', $migration_array);
  if ($version == 6) {
    $this->store
      ->set('source_base_path', $form_state
      ->getValue('d6_source_base_path'));
  }
  else {
    $this->store
      ->set('source_base_path', $form_state
      ->getValue('source_base_path'));
  }
  $this->store
    ->set('source_private_file_path', $form_state
    ->getValue('source_private_file_path'));

  // Store the retrieved system data in the private store.
  $this->store
    ->set('system_data', $system_data);
}