You are here

protected function MigrationState::getSourceState in Drupal 9

Same name and namespace in other branches
  1. 8 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;
}