Issue #2886801 by phenaproxima: Migrate D6 user reference values to D8
parent
0f37866673
commit
e96b787dc4
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\migrate_drupal\Plugin\migrate\field;
|
||||||
|
|
||||||
|
use Drupal\migrate\Plugin\MigrationInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @MigrateField(
|
||||||
|
* id = "userreference",
|
||||||
|
* core = {6},
|
||||||
|
* type_map = {
|
||||||
|
* "userreference" = "entity_reference",
|
||||||
|
* },
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class UserReference 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_user',
|
||||||
|
'source' => 'uid',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$migration->setProcessOfProperty($field_name, $process);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -95,6 +95,10 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
||||||
$this->assertSame('Klingon Empire', $node->field_company[0]->entity->label());
|
$this->assertSame('Klingon Empire', $node->field_company[0]->entity->label());
|
||||||
$this->assertSame('Romulan Empire', $node->field_company[1]->entity->label());
|
$this->assertSame('Romulan Empire', $node->field_company[1]->entity->label());
|
||||||
|
|
||||||
|
// Test that user reference field values were migrated.
|
||||||
|
$this->assertCount(1, $node->field_commander);
|
||||||
|
$this->assertSame('joe.roe', $node->field_commander[0]->entity->getUsername());
|
||||||
|
|
||||||
$node = Node::load(2);
|
$node = Node::load(2);
|
||||||
$this->assertIdentical('Test title rev 3', $node->getTitle());
|
$this->assertIdentical('Test title rev 3', $node->getTitle());
|
||||||
$this->assertIdentical('test rev 3', $node->body->value);
|
$this->assertIdentical('test rev 3', $node->body->value);
|
||||||
|
|
Loading…
Reference in New Issue