protected function MigrationState::buildDiscoveredDestinationsBySource in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildDiscoveredDestinationsBySource()
- 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 365
Class
- MigrationState
- Determines the migrate state for all modules enabled on the source.
Namespace
Drupal\migrate_drupalCode
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]);
}
$tmp = array_diff_key($source_system_data['module'], $table_data);
foreach ($tmp as $source_module => $module_data) {
if ($module_data['status']) {
$this->unmigratedSourceModules[$version][$source_module] = $module_data;
}
}
$this->migratedSourceModules[$version] = $table_data;
$this->discoveredBySource[$version] = array_map('array_unique', $discovered_upgrade_paths);
}