You are here

protected function MigrationState::buildUpgradeState in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildUpgradeState()
  2. 9 core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildUpgradeState()

Determines migration state for each source module enabled on the source.

If there are no migrations for a module and no declared state the state is set to NOT_FINISHED. When a module does not need any migrations, such as Overlay, a state of finished is declared in system.migrate_drupal.yml.

If there are migrations for a module the following happens. If the destination module is 'core' the state is set to FINISHED. If there are any occurrences of 'not_finished' in the *.migrate_drupal.yml information for this source module then the state is set to NOT_FINISHED. And finally, if there is an occurrence of 'finished' the state is set to FINISHED.

[
  'finished' => [
    'menu' => [
      'menu_link_content',
      'menu_ui',
      'system',
    ],
  ],
];

Parameters

string $version: The legacy drupal version.

array $source_system_data: The data from the source site system table.

array $migrations: An array of migrations.

Return value

array An associative array of data with keys of state, source modules and a value which is a comma separated list of destination modules. Example.

File

core/modules/migrate_drupal/src/MigrationState.php, line 298

Class

MigrationState
Determines the migrate state for all modules enabled on the source.

Namespace

Drupal\migrate_drupal

Code

protected function buildUpgradeState($version, array $source_system_data, array $migrations) {

  // Remove core profiles from the system data.
  unset($source_system_data['module']['standard'], $source_system_data['module']['minimal']);
  $this
    ->buildDiscoveredDestinationsBySource($version, $migrations, $source_system_data);
  $this
    ->buildDeclaredStateBySource($version);
  $upgrade_state = [];

  // Loop through every source module that is enabled on the source site.
  foreach ($source_system_data['module'] as $module) {

    // The source plugins check requirements requires that all
    // source_modules are enabled so do the same here.
    if ($module['status']) {
      $source_module = $module['name'];
      $upgrade_state[$this
        ->getSourceState($version, $source_module)][$source_module] = implode(', ', $this
        ->getDestinationsForSource($version, $source_module));
    }
  }
  foreach ($upgrade_state as $key => $value) {
    ksort($upgrade_state[$key]);
  }
  return $upgrade_state;
}