Commit 3eaded35 authored by webchick's avatar webchick

Issue #2550309 by webflo, phenaproxima, kaushashah: Unable to import migration...

Issue #2550309 by webflo, phenaproxima, kaushashah: Unable to import migration config-entities generated by migrate_upgrade module
parent d3c5e548
......@@ -585,8 +585,11 @@ public function calculateDependencies() {
parent::calculateDependencies();
$this->calculatePluginDependencies($this->getSourcePlugin());
$this->calculatePluginDependencies($this->getDestinationPlugin());
// Add dependencies on required migration dependencies.
foreach ($this->getMigrationDependencies()['required'] as $dependency) {
// Add hard dependencies on required migrations.
$dependencies = $this->getEntityManager()->getStorage($this->entityTypeId)
->getVariantIds($this->getMigrationDependencies()['required']);
foreach ($dependencies as $dependency) {
$this->addDependency('config', $this->getEntityType()->getConfigPrefix() . '.' . $dependency);
}
......
......@@ -92,7 +92,7 @@ public function loadMultiple(array $ids = NULL) {
* @return string[]
* The expanded list of IDs.
*/
protected function getVariantIds(array $ids) {
public function getVariantIds(array $ids) {
// Re-index the array numerically, since we need to limit the loop by size.
$ids = array_values($ids);
......
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Kernel\Entity\MigrationTest.
*/
namespace Drupal\Tests\migrate\Kernel\Entity;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\Entity\Migration;
/**
* Tests the Migration entity.
*
* @coversDefaultClass \Drupal\migrate\Entity\Migration
* @group migrate
*/
class MigrationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate'];
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies() {
$fixture_migrations = [
'd6_node__article' => 'd6_node',
'd6_node__page' => 'd6_node',
'd6_variables' => 'd6_variables',
];
foreach ($fixture_migrations as $id => $template) {
$values = [
'id' => $id,
'template' => $template,
'source' => [
'plugin' => 'empty',
],
'destination' => [
'plugin' => 'null',
],
'migration_tags' => []
];
Migration::create($values)->save();
}
$values = [
'migration_dependencies' => [
'required' => [
'd6_node:*',
'd6_variables'
]
],
'source' => [
'plugin' => 'empty',
],
'destination' => [
'plugin' => 'null',
],
];
$migration = new Migration($values, 'migration');
$expected = [
'migrate.migration.d6_node__article',
'migrate.migration.d6_node__page',
'migrate.migration.d6_variables'
];
$migration->calculateDependencies();
$this->assertEquals($expected, $migration->getDependencies()['config']);
}
}
......@@ -39,6 +39,3 @@ process:
destination:
plugin: entity_revision:node
migration_dependencies:
required:
- d6_node:*
......@@ -41,9 +41,17 @@ public function buildMigrations(array $template) {
$node_type = $row->getSourceProperty('type');
$values = $template;
$values['id'] = $template['id'] . '__' . $node_type;
$label = $template['label'];
$values['label'] = $this->t("@label (@type)", ['@label' => $label, '@type' => $node_type]);
$values['source']['node_type'] = $node_type;
// If this migration is based on the d6_node_revision template, it should
// explicitly depend on the corresponding d6_node variant.
if ($template['id'] == 'd6_node_revision') {
$values['migration_dependencies']['required'][] = 'd6_node__' . $node_type;
}
$migration = Migration::create($values);
if (isset($fields[$node_type])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment