function MigrationState::buildDeclaredStateBySource

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

Gets migration data from *.migrate_drupal.yml sorted by source module.

Parameters

string $version: The legacy Drupal version.

1 call to MigrationState::buildDeclaredStateBySource()
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 379

Class

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

Namespace

Drupal\migrate_drupal

Code

protected function buildDeclaredStateBySource($version) {
    $migration_states = $this->getMigrationStates();
    $state_by_source = [];
    $dest_by_source = [];
    $states = [
        static::FINISHED,
        static::NOT_FINISHED,
    ];
    foreach ($migration_states as $info) {
        foreach ($states as $state) {
            if (isset($info[$state][$version])) {
                foreach ($info[$state][$version] as $source => $destination) {
                    // Add the state.
                    $state_by_source[$source][] = $state;
                    // Add the destination modules.
                    $dest_by_source += [
                        $source => [],
                    ];
                    $dest_by_source[$source] = array_merge($dest_by_source[$source], (array) $destination);
                }
            }
        }
    }
    $this->stateBySource[$version] = array_map('array_unique', $state_by_source);
    $this->declaredBySource[$version] = array_map('array_unique', $dest_by_source);
}

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