Commit 0c8bbf1b authored by webchick's avatar webchick

Issue #2324353 by chx: Remove MigrateEntityDestinationFieldInterface.

parent d72c0f98
......@@ -18,9 +18,6 @@ services:
plugin.manager.migrate.id_map:
class: Drupal\migrate\Plugin\MigratePluginManager
arguments: [id_map, '@container.namespaces', '@cache.discovery', '@module_handler']
plugin.manager.migrate.entity_field:
class: Drupal\migrate\Plugin\MigratePluginManager
arguments: [entity_field, '@container.namespaces', '@cache.discovery', '@module_handler']
password_migrate:
class: Drupal\migrate\MigratePassword
arguments: ['@password_original']
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateEntityDestinationFieldInterface
*/
namespace Drupal\migrate\Plugin;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Handle the importing of a specific configurable field type.
*/
interface MigrateEntityDestinationFieldInterface {
/**
* Convert an array of values into an array structure fit for entity_create.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The field definition. For example, this can be used to check for
* required values.
* @param array $values
* The array of values.
* @return array|NULL
* This will be set in the $values array passed to entity_create() as the
* value of a configurable field of the type this class handles.
*/
public function import(FieldDefinitionInterface $field_definition, array $values = NULL);
}
......@@ -51,8 +51,8 @@ class EntityComment extends EntityContentBase {
* @param \Drupal\Core\State\StateInterface $state
* The state storage object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $entity_manager);
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
$this->state = $state;
}
......@@ -68,7 +68,6 @@ public static function create(ContainerInterface $container, array $configuratio
$migration,
$container->get('entity.manager')->getStorage($entity_type),
array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
$container->get('plugin.manager.migrate.entity_field'),
$container->get('entity.manager'),
$container->get('state')
);
......
......@@ -13,7 +13,6 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -49,9 +48,8 @@ class EntityContentBase extends Entity {
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles);
$this->migrateEntityFieldPluginManager = $plugin_manager;
$this->entityManager = $entity_manager;
}
......@@ -67,7 +65,6 @@ public static function create(ContainerInterface $container, array $configuratio
$migration,
$container->get('entity.manager')->getStorage($entity_type),
array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
$container->get('plugin.manager.migrate.entity_field'),
$container->get('entity.manager')
);
}
......@@ -76,27 +73,6 @@ public static function create(ContainerInterface $container, array $configuratio
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
if ($bundle_key = $this->getKey('bundle')) {
$bundle = $row->getDestinationProperty($bundle_key);
}
else {
$bundle = $this->storage->getEntityTypeId();
}
// Some migrations save additional data of an existing entity and only
// provide the reference to the entity, in those cases, we can not run the
// processing below. Migrations that need that need to provide the bundle.
if ($bundle) {
$field_definitions = $this->entityManager->getFieldDefinitions($this->storage->getEntityTypeId(), $bundle);
foreach ($field_definitions as $field_name => $field_definition) {
$field_type = $field_definition->getType();
if ($this->migrateEntityFieldPluginManager->getDefinition($field_type, FALSE)) {
$destination_value = $this->migrateEntityFieldPluginManager->createInstance($field_type)->import($field_definition, $row->getDestinationProperty($field_name));
// @TODO: check for NULL return? Add an unset to $row? Maybe needed in
// exception handling? Propagate exception?
$row->setDestinationProperty($field_name, $destination_value);
}
}
}
$entity = $this->getEntity($row, $old_destination_id_values);
return $this->save($entity, $old_destination_id_values);
}
......
......@@ -26,14 +26,14 @@ class EntityFile extends EntityContentBase {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager) {
$configuration += array(
'source_base_path' => '',
'source_path_property' => 'filepath',
'destination_path_property' => 'uri',
'move' => FALSE,
);
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $entity_manager);
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
}
/**
......
......@@ -53,8 +53,8 @@ class EntityUser extends EntityContentBase {
* @param \Drupal\Core\Password\PasswordInterface $password
* The password service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager, PasswordInterface $password) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $entity_manager);
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, PasswordInterface $password) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
if (isset($configuration['md5_passwords'])) {
$this->password = $password;
}
......@@ -72,7 +72,6 @@ public static function create(ContainerInterface $container, array $configuratio
$migration,
$container->get('entity.manager')->getStorage($entity_type),
array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
$container->get('plugin.manager.migrate.entity_field'),
$container->get('entity.manager'),
$container->get('password')
);
......
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