Issue #3008950 by mikelutz, quietone: Move MigrateField Plugins out of Core Library
parent
0d1e6dd0ca
commit
00cfac4fdc
|
@ -2,59 +2,24 @@
|
|||
|
||||
namespace Drupal\Core\Field\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\field\Plugin\migrate\field\Email as EmailNew;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "email",
|
||||
* core = {6,7},
|
||||
* type_map = {
|
||||
* "email" = "email"
|
||||
* },
|
||||
* source_module = "email",
|
||||
* destination_module = "core"
|
||||
* )
|
||||
* MigrateField Plugin for Drupal 6 and 7 email fields.
|
||||
*
|
||||
* @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\field\Plugin\migrate\field\Email instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3009286
|
||||
*/
|
||||
class Email extends FieldPluginBase {
|
||||
class Email extends EmailNew {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldWidgetMap() {
|
||||
return [
|
||||
'email_textfield' => 'email_default',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [
|
||||
'email_formatter_default' => 'email_mailto',
|
||||
'email_formatter_contact' => 'basic_string',
|
||||
'email_formatter_plain' => 'basic_string',
|
||||
'email_formatter_spamspan' => 'basic_string',
|
||||
'email_default' => 'email_mailto',
|
||||
'email_contact' => 'basic_string',
|
||||
'email_plain' => 'basic_string',
|
||||
'email_spamspan' => 'basic_string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'sub_process',
|
||||
'source' => $field_name,
|
||||
'process' => [
|
||||
'value' => 'email',
|
||||
],
|
||||
];
|
||||
$migration->setProcessOfProperty($field_name, $process);
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
|
||||
@trigger_error(__NAMESPACE__ . '\Email is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\field\Plugin\migrate\field\Email instead. See https://www.drupal.org/node/3009286', E_USER_DEPRECATED);
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,30 +2,24 @@
|
|||
|
||||
namespace Drupal\Core\Field\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\field\Plugin\migrate\field\d7\EntityReference as EntityReferenceNew;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "entityreference",
|
||||
* type_map = {
|
||||
* "entityreference" = "entity_reference",
|
||||
* },
|
||||
* core = {7},
|
||||
* source_module = "entityreference",
|
||||
* destination_module = "core"
|
||||
* )
|
||||
* MigrateField plugin for Drupal 7 entity_reference fields.
|
||||
*
|
||||
* @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\field\Plugin\migrate\field\d7\EntityReference instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3009286
|
||||
*/
|
||||
class EntityReference extends FieldPluginBase {
|
||||
class EntityReference extends EntityReferenceNew {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [
|
||||
'entityreference_label' => 'entity_reference_label',
|
||||
'entityreference_entity_id' => 'entity_reference_entity_id',
|
||||
'entityreference_entity_view' => 'entity_reference_entity_view',
|
||||
];
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
|
||||
@trigger_error(__NAMESPACE__ . '\EntityReference is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\field\Plugin\migrate\field\d7\EntityReference instead. See https://www.drupal.org/node/3009286', E_USER_DEPRECATED);
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,19 +2,24 @@
|
|||
|
||||
namespace Drupal\Core\Field\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\field\Plugin\migrate\field\d7\NumberField as NumberFieldNew;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "number_default",
|
||||
* type_map = {
|
||||
* "number_integer" = "integer",
|
||||
* "number_decimal" = "decimal",
|
||||
* "number_float" = "float",
|
||||
* },
|
||||
* core = {7},
|
||||
* source_module = "number",
|
||||
* destination_module = "core"
|
||||
* )
|
||||
* MigrateField plugin for Drupal 7 number fields.
|
||||
*
|
||||
* @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\field\Plugin\migrate\field\d7\NumberField instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3009286
|
||||
*/
|
||||
class NumberField extends FieldPluginBase {}
|
||||
class NumberField extends NumberFieldNew {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
|
||||
@trigger_error(__NAMESPACE__ . '\NumberField is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\field\Plugin\migrate\field\d7\NumberField instead. See https://www.drupal.org/node/3009286', E_USER_DEPRECATED);
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\field\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* MigrateField Plugin for Drupal 6 and 7 email fields.
|
||||
*
|
||||
* @MigrateField(
|
||||
* id = "email",
|
||||
* core = {6,7},
|
||||
* type_map = {
|
||||
* "email" = "email"
|
||||
* },
|
||||
* source_module = "email",
|
||||
* destination_module = "core"
|
||||
* )
|
||||
*/
|
||||
class Email extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldWidgetMap() {
|
||||
return [
|
||||
'email_textfield' => 'email_default',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [
|
||||
'email_formatter_default' => 'email_mailto',
|
||||
'email_formatter_contact' => 'basic_string',
|
||||
'email_formatter_plain' => 'basic_string',
|
||||
'email_formatter_spamspan' => 'basic_string',
|
||||
'email_default' => 'email_mailto',
|
||||
'email_contact' => 'basic_string',
|
||||
'email_plain' => 'basic_string',
|
||||
'email_spamspan' => 'basic_string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'sub_process',
|
||||
'source' => $field_name,
|
||||
'process' => [
|
||||
'value' => 'email',
|
||||
],
|
||||
];
|
||||
$migration->setProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\field\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* MigrateField plugin for Drupal 7 entity_reference fields.
|
||||
*
|
||||
* @MigrateField(
|
||||
* id = "entityreference",
|
||||
* type_map = {
|
||||
* "entityreference" = "entity_reference",
|
||||
* },
|
||||
* core = {7},
|
||||
* source_module = "entityreference",
|
||||
* destination_module = "core"
|
||||
* )
|
||||
*/
|
||||
class EntityReference extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [
|
||||
'entityreference_label' => 'entity_reference_label',
|
||||
'entityreference_entity_id' => 'entity_reference_entity_id',
|
||||
'entityreference_entity_view' => 'entity_reference_entity_view',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\field\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* MigrateField plugin for Drupal 7 number fields.
|
||||
*
|
||||
* @MigrateField(
|
||||
* id = "number_default",
|
||||
* type_map = {
|
||||
* "number_integer" = "integer",
|
||||
* "number_decimal" = "decimal",
|
||||
* "number_float" = "float",
|
||||
* },
|
||||
* core = {7},
|
||||
* source_module = "number",
|
||||
* destination_module = "core"
|
||||
* )
|
||||
*/
|
||||
class NumberField extends FieldPluginBase {}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\Field;
|
||||
|
||||
use Drupal\Core\Field\Plugin\migrate\field\d7\EntityReference;
|
||||
use Drupal\Core\Field\Plugin\migrate\field\d7\NumberField;
|
||||
use Drupal\Core\Field\Plugin\migrate\field\Email;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Test trigger_error is fired when deprecated classes are instantiated.
|
||||
*
|
||||
* @group Field
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateFieldDeprecationTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests trigger_error when an Email object is created.
|
||||
*
|
||||
* @expectedDeprecation Drupal\Core\Field\Plugin\migrate\field\Email is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\field\Plugin\migrate\field\Email instead. See https://www.drupal.org/node/3009286
|
||||
*/
|
||||
public function testDeprecatedEmail() {
|
||||
new Email([], 'email', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests trigger_error when an EntityReference object is created.
|
||||
*
|
||||
* @expectedDeprecation Drupal\Core\Field\Plugin\migrate\field\d7\EntityReference is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\field\Plugin\migrate\field\d7\EntityReference instead. See https://www.drupal.org/node/3009286
|
||||
*/
|
||||
public function testDeprecatedEntityReference() {
|
||||
new EntityReference([], 'entityreference', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests trigger_error when a NumberField object is created.
|
||||
*
|
||||
* @expectedDeprecation Drupal\Core\Field\Plugin\migrate\field\d7\NumberField is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\field\Plugin\migrate\field\d7\NumberField instead. See https://www.drupal.org/node/3009286
|
||||
*/
|
||||
public function testDeprecatedNumberField() {
|
||||
new NumberField([], 'number_default', []);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue