You are here

public function MigrationBuilder::createMigrations in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/migrate/src/MigrationBuilder.php \Drupal\migrate\MigrationBuilder::createMigrations()

Builds migration entities from templates.

Parameters

array $templates: The parsed templates (each of which is an array parsed from YAML), keyed by ID.

Return value

\Drupal\migrate\Entity\MigrationInterface[] The migration entities derived from the templates.

File

core/modules/migrate/src/MigrationBuilder.php, line 45
Contains \Drupal\migrate\MigrationBuilder.

Class

MigrationBuilder
Builds migration entities from migration templates.

Namespace

Drupal\migrate

Code

public function createMigrations(array $templates) {

  /** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
  $migrations = [];
  foreach ($templates as $template_id => $template) {
    if (isset($template['builder'])) {
      $variants = $this->builderManager
        ->createInstance($template['builder']['plugin'], $template['builder'])
        ->buildMigrations($template);
    }
    else {
      $variants = array(
        Migration::create($template),
      );
    }

    /** @var \Drupal\migrate\Entity\MigrationInterface[] $variants */
    foreach ($variants as $variant) {
      $variant
        ->set('template', $template_id);
    }
    $migrations = array_merge($migrations, $variants);
  }
  return $migrations;
}