protected function Migrator::load in Lightning Workflow 8.2
Same name and namespace in other branches
- 8.3 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.
\stdClass $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 261
Class
- Migrator
- This class is final because the migration is not an API and should not be extended or re-used.
Namespace
Drupal\lightning_schedulerCode
protected function load(EntityStorageInterface $storage, \stdClass $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;
}