You are here

protected function MigrateUpgradeDrushRunner::expandNodeMigrations in Migrate Upgrade 8.2

For D6 term_node migrations, make sure the nid reference is expanded.

Parameters

\Drupal\migrate\Plugin\MigrationInterface $migration: Migration to alter with the list of node migrations.

1 call to MigrateUpgradeDrushRunner::expandNodeMigrations()
MigrateUpgradeDrushRunner::configure in src/MigrateUpgradeDrushRunner.php
From the provided source information, instantiate the appropriate migrations in the active configuration.

File

src/MigrateUpgradeDrushRunner.php, line 113

Class

MigrateUpgradeDrushRunner

Namespace

Drupal\migrate_upgrade

Code

protected function expandNodeMigrations(MigrationInterface $migration) {
  $source = $migration
    ->getSourceConfiguration();

  // Track the node migrations as we see them.
  if ($source['plugin'] == 'd6_node') {
    $this->nodeMigrations[] = $migration
      ->id();
  }
  elseif ($source['plugin'] == 'd6_term_node' || $source['plugin'] == 'd6_term_node_revision') {
    if ($source['plugin'] == 'd6_term_node') {
      $id_property = 'nid';
    }
    else {
      $id_property = 'vid';
    }

    // If the ID mapping is to the underived d6_node migration, replace
    // it with an expanded list of node migrations.
    $process = $migration
      ->getProcess();
    $new_nid_process = [];
    foreach ($process[$id_property] as $delta => $plugin_configuration) {
      if ($plugin_configuration['plugin'] == 'migration' && is_string($plugin_configuration['migration']) && substr($plugin_configuration['migration'], -7) == 'd6_node') {
        $plugin_configuration['migration'] = $this->nodeMigrations;
      }
      $new_nid_process[$delta] = $plugin_configuration;
    }
    $migration
      ->setProcessOfProperty($id_property, $new_nid_process);
  }
}