Issue #2814949 by phenaproxima: Support migration of node reference field values from Drupal 6
parent
d0fceeeda9
commit
12ac3a61a2
|
@ -0,0 +1,43 @@
|
|||
<?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 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
// 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);
|
||||
|
|
Loading…
Reference in New Issue