You are here

protected function MigrationCreationTrait::getMigrations in Migrate Upgrade 8

Gets the migrations for import.

Uses the migration template connection to ensure that only the relevant migrations are returned.

Parameters

array $migration_templates: Migration template.

Return value

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

2 calls to MigrationCreationTrait::getMigrations()
MigrateUpgradeForm::validateCredentialForm in src/Form/MigrateUpgradeForm.php
Validation handler for the credentials form.
MigrationCreationTrait::createMigrations in src/MigrationCreationTrait.php
Saves the migrations for import from the provided template connection.

File

src/MigrationCreationTrait.php, line 120
Contains \Drupal\migrate_upgrade\MigrationCreationTrait.

Class

MigrationCreationTrait
Creates the appropriate migrations for a given source Drupal database.

Namespace

Drupal\migrate_upgrade

Code

protected function getMigrations(array $migration_templates) {

  // Let the builder service create our migration configuration entities from
  // the templates, expanding them to multiple entities where necessary.

  /** @var \Drupal\migrate\MigrationBuilder $builder */
  $builder = \Drupal::service('migrate.migration_builder');
  $initial_migrations = $builder
    ->createMigrations($migration_templates);
  $migrations = [];
  foreach ($initial_migrations as $migration) {
    try {
      $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) {
    } catch (PluginNotFoundException $e) {
    }
  }
  return $migrations;
}