diff --git a/core/modules/book/src/Plugin/migrate/destination/Book.php b/core/modules/book/src/Plugin/migrate/destination/Book.php index 3659b34..0e065b6 100644 --- a/core/modules/book/src/Plugin/migrate/destination/Book.php +++ b/core/modules/book/src/Plugin/migrate/destination/Book.php @@ -24,7 +24,7 @@ protected static function getEntityTypeId($plugin_id) { /** * {@inheritdoc} */ - protected function updateEntity(EntityInterface $entity, Row $row) { + protected function updateEntity(EntityInterface &$entity, Row $row) { $entity->book = $row->getDestinationProperty('book'); } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php index 0cebbd0..f5a3787 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -170,7 +170,7 @@ protected function getEntity(Row $row, array $old_destination_id_values) { $entity_id = reset($old_destination_id_values) ?: $this->getEntityId($row); if (!empty($entity_id) && ($entity = $this->storage->load($entity_id))) { // Allow updateEntity() to change the entity. - $entity = $this->updateEntity($entity, $row) ?: $entity; + $this->updateEntity($entity, $row) ?: $entity; } else { // Attempt to ensure we always have a bundle. diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php index 3e18d28..206722e 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -200,6 +200,8 @@ public function getIds() { /** * Updates an entity with the new values from row. * + * Note that the entity passed in will also be updated. + * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to update. * @param \Drupal\migrate\Row $row @@ -208,7 +210,7 @@ public function getIds() { * @return \Drupal\Core\Entity\EntityInterface * An updated entity from row values. */ - protected function updateEntity(EntityInterface $entity, Row $row) { + protected function updateEntity(EntityInterface &$entity, Row $row) { $empty_destinations = $row->getEmptyDestinationProperties(); // By default, an update will be preserved. $rollback_action = MigrateIdMapInterface::ROLLBACK_PRESERVE; diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php index ff3f007..db04888 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php @@ -162,7 +162,7 @@ protected function getEntity(Row $row, array $old_destination_id_values) { } // We need to update the entity, so that the destination row IDs are // correct. - $entity = $this->updateEntity($entity, $row); + $this->updateEntity($entity, $row); $entity->isDefaultRevision(FALSE); return $entity; } diff --git a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php index 5a63f06..87b152d 100644 --- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -230,7 +230,7 @@ public function save(ContentEntityInterface $entity, array $old_destination_id_v * workings of its implementation which would trickle into mock assertions. An * empty implementation avoids this. */ - protected function updateEntity(EntityInterface $entity, Row $row) { + protected function updateEntity(EntityInterface &$entity, Row $row) { return $entity; }