function MigrationConfigurationTrait::getMigrations

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

Gets the migrations for import.

Parameters

string $database_state_key: The state key.

int $drupal_version: The version of Drupal we're getting the migrations for.

Return value

\Drupal\migrate\Plugin\MigrationInterface[] The migrations for import.

1 call to MigrationConfigurationTrait::getMigrations()
CredentialForm::setupMigrations in core/modules/migrate_drupal_ui/src/Form/CredentialForm.php
Gets and stores information for this migration in temporary store.

File

core/modules/migrate_drupal/src/MigrationConfigurationTrait.php, line 122

Class

MigrationConfigurationTrait
Configures the appropriate migrations for a given source Drupal database.

Namespace

Drupal\migrate_drupal

Code

protected function getMigrations($database_state_key, $drupal_version) {
    $version_tag = 'Drupal ' . $drupal_version;
    
    /** @var \Drupal\migrate\Plugin\MigrationInterface[] $all_migrations */
    $all_migrations = $this->getMigrationPluginManager()
        ->createInstancesByTag($version_tag);
    // Unset the node migrations that should not run based on the type of node
    // migration. That is, if this is a complete node migration then unset the
    // classic node migrations and if this is a classic node migration then
    // unset the complete node migrations.
    $type = NodeMigrateType::getNodeMigrateType(\Drupal::database(), $drupal_version);
    switch ($type) {
        case NodeMigrateType::NODE_MIGRATE_TYPE_COMPLETE:
            $patterns = '/(d' . $drupal_version . '_node:)|(d' . $drupal_version . '_node_translation:)|(d' . $drupal_version . '_node_revision:)|(d7_node_entity_translation:)/';
            break;
        case NodeMigrateType::NODE_MIGRATE_TYPE_CLASSIC:
            $patterns = '/(d' . $drupal_version . '_node_complete:)/';
            break;
    }
    foreach ($all_migrations as $key => $migrations) {
        if (preg_match($patterns, $key)) {
            unset($all_migrations[$key]);
        }
    }
    $migrations = [];
    foreach ($all_migrations as $migration) {
        // Skip migrations tagged with any of the follow-up migration tags. They
        // will be derived and executed after the migrations on which they depend
        // have been successfully executed.
        // @see Drupal\migrate_drupal\Plugin\MigrationWithFollowUpInterface
        if (!empty(array_intersect($migration->getMigrationTags(), $this->getFollowUpMigrationTags()))) {
            continue;
        }
        try {
            // @todo https://drupal.org/node/2681867 We should be able to validate
            //   the entire migration at this point.
            $source_plugin = $migration->getSourcePlugin();
            if ($source_plugin instanceof RequirementsInterface) {
                $source_plugin->checkRequirements();
            }
            $destination_plugin = $migration->getDestinationPlugin();
            if ($destination_plugin instanceof RequirementsInterface) {
                $destination_plugin->checkRequirements();
            }
            $migrations[] = $migration;
        } catch (RequirementsException $e) {
            // Migrations which are not applicable given the source and destination
            // site configurations (e.g., what modules are enabled) will be silently
            // ignored.
        }
    }
    return $migrations;
}

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