diff -u b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php --- b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php @@ -21,6 +21,20 @@ class Entity extends DestinationBase implements ContainerFactoryPluginInterface { /** + * The entity info definition. + * + * @var array + */ + protected $entityInfo; + + /** + * The entity storage controller. + * + * @var \Drupal\Core\Entity\EntityStorageControllerInterface + */ + protected $storageController; + + /** * The plugin manager handling entity_field migrate plugins. * * @var \Drupal\migrate\Plugin\MigratePluginManager @@ -28,6 +42,13 @@ protected $migrateEntityFieldPluginManager; /** + * The field info service. + * + * @var \Drupal\field\FieldInfo + */ + protected $fieldInfo; + + /** * Constructs an entity destination plugin. * * @param array $configuration @@ -46,6 +67,7 @@ * The field info object. */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, array $entity_info, EntityStorageControllerInterface $storage_controller, MigratePluginManager $plugin_manager, FieldInfo $field_info) { + parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityInfo = $entity_info; $this->storageController = $storage_controller; $this->migrateEntityFieldPluginManager = $plugin_manager; @@ -93,7 +115,9 @@ } */ // @TODO: validate! this will fatal if create() fails. - $this->storageController->create($row->getDestination())->save(); + $entity = $this->storageController->create($row->getDestination()); + $entity->save(); + return array($entity->id()); } /** diff -u b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php --- b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php @@ -25,6 +25,7 @@ } function testUserRole() { + /** @var \Drupal\migrate\entity\Migration $migration */ $migration = entity_load('migration', 'd6_user_role'); $dumps = array( drupal_get_path('module', 'migrate_drupal') . '/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6UserRole.php', @@ -33,11 +34,13 @@ $executable = new MigrateExecutable($migration, new MigrateMessage()); $executable->import(); - $migrate_test_role_1 = entity_load('user_role', 'migrate_test_role_1'); - $this->assertTrue(is_object($migrate_test_role_1), 'The migrated test role 1 was retrieved from the database.'); + $rid = 'migrate_test_role_1'; + $migrate_test_role_1 = entity_load('user_role', $rid); + $this->assertEqual($migrate_test_role_1->id(), $rid); $this->assertEqual($migrate_test_role_1->permissions, array(0 => 'migrate test role 1 test permission')); - $migrate_test_role_2 = entity_load('user_role', 'migrate_test_role_2'); - $this->assertTrue(is_object($migrate_test_role_2), 'The migrated test role 2 was retrieved from the database.'); + $this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationID(array(3))); + $rid = 'migrate_test_role_2'; + $migrate_test_role_2 = entity_load('user_role', $rid); $this->assertEqual($migrate_test_role_2->permissions, array( 'migrate test role 2 test permission', 'use PHP for settings', @@ -55,6 +58,8 @@ 'administer nodes', 'access content overview', )); + $this->assertEqual($migrate_test_role_2->id(), $rid); + $this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationID(array(4))); } }