diff --git a/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/EntityReferenceRevisions.php b/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/EntityReferenceRevisions.php index 54388cc..d9dadc4 100644 --- a/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/EntityReferenceRevisions.php +++ b/core/modules/migrate/tests/modules/migrate_events_test/src/Plugin/migrate/destination/EntityReferenceRevisions.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\migrate\Plugin\migrate\destination\EntityRevision; use Drupal\migrate\Row; +use Drupal\migrate\MigrateException; /** * Provides entity_reference_revisions destination plugin. @@ -71,13 +72,13 @@ public function getIds() { * {@inheritdoc} */ protected function getEntity(Row $row, array $oldDestinationIdValues) { - $entityId = $oldDestinationIdValues ? + $entity_id = $oldDestinationIdValues ? reset($oldDestinationIdValues) : $row->getDestinationProperty($this->getKey('id')); - $revisionId = $oldDestinationIdValues ? + $revision_id = $oldDestinationIdValues ? array_pop($oldDestinationIdValues) : $row->getDestinationProperty($this->getKey('revision')); - if (!empty($entityId) && !empty($revisionId) && ($entity = $this->loadEntityReferenceRevision($entityId, $revisionId))) { + if (!empty($entity_id) && !empty($revision_id) && ($entity =$this->storage->loadRevision($revision_id))) { $entity->setNewRevision(FALSE); } else { @@ -112,7 +113,7 @@ public function rollback(array $destination_identifiers) { * The IDs of the destination object to delete. */ protected function rollbackTranslation(array $destination_identifiers) { - $entity = $this->loadEntityReferenceRevision(reset($destination_identifiers), array_pop($destination_identifiers)); + $entity = $this->storage->loadRevision($destination_identifiers[1]); if ($entity && $entity instanceof TranslatableInterface) { if ($key = $this->getKey('langcode')) { if (isset($destination_identifier[$key])) { @@ -137,24 +138,9 @@ protected function rollbackTranslation(array $destination_identifiers) { * The IDs of the destination object to delete. */ protected function rollbackNonTranslation(array $destination_identifiers) { - $entity = $this->loadEntityReferenceRevision(reset($destination_identifiers), array_pop($destination_identifiers)); + $entity = $this->storage->loadRevision($destination_identifiers[1]); if ($entity) { $entity->delete(); } } - - /** - * Loads one entity reference revision entity. - * - * @param mixed $id - * The ID of the entity to load. - * - * @return \Drupal\Core\Entity\EntityInterface|null - * An entity object. NULL if no matching entity is found. - */ - public function loadEntityReferenceRevision($entityId, $revisionId) { - $entities = $this->storage->loadByProperties([$this->getKey('id') => $entityId, $this->getKey('revision') => $revisionId]); - return reset($entities) ?: NULL; - } - } diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/MigrateEntityReferenceRevisions.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/MigrateEntityReferenceRevisions.php index 90390ec..2b8ae69 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/MigrateEntityReferenceRevisions.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Derivative/MigrateEntityReferenceRevisions.php @@ -5,7 +5,12 @@ use Drupal\entity_reference_revisions\Plugin\migrate\destination\EntityReferenceRevisions; use Drupal\migrate\Plugin\Derivative\MigrateEntityRevision; +/** + * Class MigrateEntityReferenceRevisions + * @package Drupal\entity_reference_revisions\Plugin\Derivative + */ class MigrateEntityReferenceRevisions extends MigrateEntityRevision { + /** * {@inheritdoc} */