Commit 12ac3a61 authored by catch's avatar catch

Issue #2814949 by phenaproxima: Support migration of node reference field values from Drupal 6

parent d0fceeed
<?php
namespace Drupal\migrate_drupal\Plugin\migrate\field;
use Drupal\migrate\Plugin\MigrationInterface;
/**
* @MigrateField(
* id = "nodereference",
* core = {6},
* type_map = {
* "nodereference" = "entity_reference",
* },
* )
*/
class NodeReference extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [];
}
/**
* {@inheritdoc}
*/
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'iterator',
'source' => $field_name,
'process' => [
'target_id' => [
'plugin' => 'migration_lookup',
'migration' => 'd6_node',
'source' => 'nid',
],
],
];
$migration->setProcessOfProperty($field_name, $process);
}
}
......@@ -89,6 +89,12 @@ public function testNode() {
// Test that an email field is migrated.
$this->assertSame('PrincessRuwenne@example.com', $node->field_test_email->value);
// Test that node reference field values were migrated.
$node = Node::load(18);
$this->assertCount(2, $node->field_company);
$this->assertSame('Klingon Empire', $node->field_company[0]->entity->label());
$this->assertSame('Romulan Empire', $node->field_company[1]->entity->label());
$node = Node::load(2);
$this->assertIdentical('Test title rev 3', $node->getTitle());
$this->assertIdentical('test rev 3', $node->body->value);
......
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