You are here

protected function Migrator::load in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8.2 modules/lightning_scheduler/src/Migrator.php \Drupal\lightning_scheduler\Migrator::load()

Loads an entity to be migrated.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage handler.

object $item: The relevant entity information. See ::migrate() for details.

Return value

\Drupal\Core\Entity\ContentEntityInterface The loaded entity, with $entity->original set.

1 call to Migrator::load()
Migrator::migrate in modules/lightning_scheduler/src/Migrator.php
Migrates a single entity.

File

modules/lightning_scheduler/src/Migrator.php, line 260

Class

Migrator
The migration is not an API and should not be extended or re-used.

Namespace

Drupal\lightning_scheduler

Code

protected function load(EntityStorageInterface $storage, $item) {
  $entity_type = $storage
    ->getEntityType();
  $id_key = $entity_type
    ->getKey('id');
  if ($entity_type
    ->isRevisionable()) {
    $vid_key = $entity_type
      ->getKey('revision');
  }
  if ($entity_type
    ->isTranslatable()) {
    $language_key = $entity_type
      ->getKey('langcode');
  }

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = isset($vid_key) ? $storage
    ->loadRevision($item->{$vid_key}) : $storage
    ->load($item->{$id_key});
  if (isset($language_key)) {
    $entity = $entity
      ->getTranslation($item->{$language_key});
  }
  $entity->original = $storage
    ->loadUnchanged($item->{$id_key});
  return $entity;
}