protected function MigrationState::buildUpgradeState in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate_drupal/src/MigrationState.php \Drupal\migrate_drupal\MigrationState::buildUpgradeState()
- 10 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.
1 call to MigrationState::buildUpgradeState()
- MigrationState::getUpgradeStates in core/
modules/ migrate_drupal/ src/ MigrationState.php - Gets the upgrade states for all enabled source modules.
File
- core/
modules/ migrate_drupal/ src/ MigrationState.php, line 313
Class
- MigrationState
- Determines the migrate state for all modules enabled on the source.
Namespace
Drupal\migrate_drupalCode
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'];
// If there is not a declared state for this source module then use the
// legacy method for determining the migration state.
if (!isset($this->stateBySource[$version][$source_module])) {
// No migrations found for this source module.
if (!empty($this->unmigratedSourceModules[$version]) && array_key_exists($source_module, $this->unmigratedSourceModules[$version])) {
$upgrade_state[static::NOT_FINISHED][$source_module] = '';
continue;
}
if (!empty($this->migratedSourceModules[$version]) && array_key_exists($source_module, $this->migratedSourceModules[$version])) {
@trigger_error(sprintf("Using migration plugin definitions to determine the migration state of the module '%s' is deprecated in Drupal 8.7. Add the module to a migrate_drupal.yml file. See https://www.drupal.org/node/2929443", $source_module), E_USER_DEPRECATED);
if (array_diff(array_keys($this->migratedSourceModules[$version][$source_module]), $this->enabledModules)) {
$upgrade_state[static::NOT_FINISHED][$source_module] = implode(', ', array_keys($this->migratedSourceModules[$version][$source_module]));
continue;
}
$upgrade_state[static::FINISHED][$source_module] = implode(', ', array_keys($this->migratedSourceModules[$version][$source_module]));
}
continue;
}
$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;
}