function MigrationState::buildDiscoveredDestinationsBySource

Same name in other branches
  1. 9 core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildDiscoveredDestinationsBySource()
  2. 8.9.x core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildDiscoveredDestinationsBySource()
  3. 10 core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildDiscoveredDestinationsBySource()

Builds migration source and destination module information.

Parameters

string $version: The legacy Drupal version.

array $migrations: The discovered migrations.

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

1 call to MigrationState::buildDiscoveredDestinationsBySource()
MigrationState::buildUpgradeState in core/modules/migrate_drupal/src/MigrationState.php
Determines migration state for each source module enabled on the source.

File

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

Class

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

Namespace

Drupal\migrate_drupal

Code

protected function buildDiscoveredDestinationsBySource($version, array $migrations, array $source_system_data) {
    $discovered_upgrade_paths = [];
    $table_data = [];
    foreach ($migrations as $migration) {
        $migration_id = $migration->getPluginId();
        $source_module = $migration->getSourcePlugin()
            ->getSourceModule();
        if (!$source_module) {
            $this->messenger()
                ->addError($this->t('Source module not found for @migration_id.', [
                '@migration_id' => $migration_id,
            ]));
        }
        $destination_module = $migration->getDestinationPlugin()
            ->getDestinationModule();
        if (!$destination_module) {
            $this->messenger()
                ->addError($this->t('Destination module not found for @migration_id.', [
                '@migration_id' => $migration_id,
            ]));
        }
        if ($source_module && $destination_module) {
            $discovered_upgrade_paths[$source_module][] = $destination_module;
            $table_data[$source_module][$destination_module][$migration_id] = $migration->label();
        }
    }
    // Add entries for the field plugins to discovered_upgrade_paths.
    $definitions = $this->fieldPluginManager
        ->getDefinitions();
    foreach ($definitions as $definition) {
        // This is not strict so that we find field plugins with an annotation
        // where the Drupal core version is an integer and when it is a string.
        if (in_array($version, $definition['core'])) {
            $source_module = $definition['source_module'];
            $destination_module = $definition['destination_module'];
            $discovered_upgrade_paths[$source_module][] = $destination_module;
            $table_data[$source_module][$destination_module][$definition['id']] = $definition['id'];
        }
    }
    ksort($table_data);
    foreach ($table_data as $source_module => $destination_module_info) {
        ksort($table_data[$source_module]);
    }
    $this->discoveredBySource[$version] = array_map('array_unique', $discovered_upgrade_paths);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.