Issue #2665196 by rakesh.gectcr, quietone, Manuel Garcia, Jo Fitzgerald, webflo, mikeryan, phenaproxima, heddn: Migration for email fields is missing
parent
7e3527ed2f
commit
882537ab56
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Field\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "email",
|
||||
* core = {6,7},
|
||||
* type_map = {
|
||||
* "email" = "email"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class Email extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldWidgetMap() {
|
||||
return [
|
||||
'email_textfield' => 'email_default',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [
|
||||
'email_formatter_default' => 'basic_string',
|
||||
'email_formatter_contact' => 'basic_string',
|
||||
'email_formatter_plain' => 'basic_string',
|
||||
'email_formatter_spamspan' => 'basic_string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'iterator',
|
||||
'source' => $field_name,
|
||||
'process' => [
|
||||
'value' => 'email',
|
||||
],
|
||||
];
|
||||
$migration->setProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -70,6 +70,10 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
|
|||
$this->assertIdentical('1.2', $field_storage->getSetting('allowed_values')['1.2'], t('First allowed value is set to 1.2'));
|
||||
$this->assertIdentical('2.1', $field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value is set to 1.2'));
|
||||
|
||||
// Email field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_email');
|
||||
$this->assertSame("email", $field_storage->getType(), t('Field type is @fieldtype. It should be email.', ['@fieldtype' => $field_storage->getType()]));
|
||||
|
||||
// Float field with a single checkbox.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_float_single_checkbox');
|
||||
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', ['@fieldtype' => $field_storage->getType()]));
|
||||
|
|
|
|||
|
|
@ -3406,7 +3406,7 @@ $connection->insert('content_type_story')
|
|||
'field_test_date_value' => NULL,
|
||||
'field_test_datestamp_value' => NULL,
|
||||
'field_test_datetime_value' => NULL,
|
||||
'field_test_email_email' => NULL,
|
||||
'field_test_email_email' => 'PrincessRuwenne@example.com',
|
||||
'field_test_filefield_fid' => '5',
|
||||
'field_test_filefield_list' => '1',
|
||||
'field_test_filefield_data' => 'a:1:{s:11:"description";s:4:"desc";}',
|
||||
|
|
@ -3435,7 +3435,7 @@ $connection->insert('content_type_story')
|
|||
'field_test_date_value' => NULL,
|
||||
'field_test_datestamp_value' => NULL,
|
||||
'field_test_datetime_value' => NULL,
|
||||
'field_test_email_email' => NULL,
|
||||
'field_test_email_email' => 'PrincessRuwenne@example.com',
|
||||
'field_test_filefield_fid' => NULL,
|
||||
'field_test_filefield_list' => NULL,
|
||||
'field_test_filefield_data' => NULL,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
$this->assertIdentical('desc', $node->field_test_filefield->description);
|
||||
$this->assertIdentical('4', $node->field_test_filefield->target_id);
|
||||
|
||||
// Test that an email field is migrated.
|
||||
$this->assertSame('PrincessRuwenne@example.com', $node->field_test_email->value);
|
||||
|
||||
$node = Node::load(2);
|
||||
$this->assertIdentical('Test title rev 3', $node->getTitle());
|
||||
$this->assertIdentical('test rev 3', $node->body->value);
|
||||
|
|
|
|||
|
|
@ -150,6 +150,9 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
|
|||
$this->assertIdentical('93', $node->field_images->height);
|
||||
$this->assertIdentical('http://google.com', $node->field_link->uri);
|
||||
$this->assertIdentical('Click Here', $node->field_link->title);
|
||||
// Test that an email field is migrated.
|
||||
$this->assertSame('default@example.com', $node->field_email->value);
|
||||
$this->assertSame('another@example.com', $node->field_email[1]->value);
|
||||
|
||||
$node = Node::load(2);
|
||||
$this->assertSame('en', $node->langcode->value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue