function MigrationState::getSourceState

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

Tests if a destination exists for the given source module.

Parameters

string $version: Source version of Drupal.

string $source_module: Source module.

Return value

string Migration state, either 'finished' or 'not_finished'.

File

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

Class

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

Namespace

Drupal\migrate_drupal

Code

protected function getSourceState($version, $source_module) {
    // The state is finished only when no declarations of 'not_finished'
    // were found and each destination module is enabled.
    if (!($destinations = $this->getDestinationsForSource($version, $source_module))) {
        // No discovered or declared state.
        return MigrationState::NOT_FINISHED;
    }
    if (!isset($this->stateBySource[$version][$source_module])) {
        // No declared state.
        return MigrationState::NOT_FINISHED;
    }
    if (in_array(MigrationState::NOT_FINISHED, $this->stateBySource[$version][$source_module], TRUE) || !in_array(MigrationState::FINISHED, $this->stateBySource[$version][$source_module], TRUE)) {
        return MigrationState::NOT_FINISHED;
    }
    if (array_diff($destinations, $this->enabledModules)) {
        return MigrationState::NOT_FINISHED;
    }
    return MigrationState::FINISHED;
}

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