Commit fcb679d8 authored by alexpott's avatar alexpott

Issue #2405023 by benjy: Cannot create base_field_override entity, ID already exists

parent 20a76f00
......@@ -106,7 +106,7 @@ public function fields(MigrationInterface $migration = NULL) {
* The entity we're importing into.
*/
protected function getEntity(Row $row, array $old_destination_id_values) {
$entity_id = $old_destination_id_values ? reset($old_destination_id_values) : $row->getDestinationProperty($this->getKey('id'));
$entity_id = $old_destination_id_values ? reset($old_destination_id_values) : $this->getEntityId($row);
if (!empty($entity_id) && ($entity = $this->storage->load($entity_id))) {
$this->updateEntity($entity, $row);
}
......@@ -125,6 +125,18 @@ protected function getEntity(Row $row, array $old_destination_id_values) {
return $entity;
}
/**
* Get the entity id of the row.
*
* @param \Drupal\migrate\Row $row
* The row of data.
* @return string
* The entity id for the row we're importing.
*/
protected function getEntityId(Row $row) {
return $row->getDestinationProperty($this->getKey('id'));
}
/**
* Returns a specific entity key.
*
......
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityBaseFieldOverride
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Row;
/**
* @MigrateDestination(
* id = "entity:base_field_override"
* )
*/
class EntityBaseFieldOverride extends EntityConfigBase {
/**
* {@inheritdoc}
*/
protected function getEntityId(Row $row) {
$entity_type = $row->getDestinationProperty('entity_type');
$bundle = $row->getDestinationProperty('bundle');
$field_name = $row->getDestinationProperty('field_name');
return "$entity_type.$bundle.$field_name";
}
}
......@@ -44,6 +44,9 @@ public function setUp() {
entity_create('node_type', array('type' => 'event'))->save();
entity_create('node_type', array('type' => 'book'))->save();
// Create a config entity that already exists.
entity_create('base_field_override', array('field_name' => 'promote', 'entity_type' => 'node', 'bundle' => 'page',))->save();
$id_mappings = array(
'd6_node_type' => array(
array(array('test_page'), array('test_page')),
......
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