You are here

protected function ContentEntity::yieldEntities in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\ContentEntity::yieldEntities()
  2. 9 core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\ContentEntity::yieldEntities()

Loads and yields entities, one at a time.

Parameters

array $ids: The entity IDs.

Return value

\Generator An iterable of the loaded entities.

1 call to ContentEntity::yieldEntities()
ContentEntity::initializeIterator in core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
Initializes the iterator with the source data.

File

core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php, line 181

Class

ContentEntity
Source plugin to get content entities from the current version of Drupal.

Namespace

Drupal\migrate_drupal\Plugin\migrate\source

Code

protected function yieldEntities(array $ids) {
  $storage = $this->entityTypeManager
    ->getStorage($this->entityType
    ->id());
  foreach ($ids as $id) {

    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $storage
      ->load($id);
    (yield $this
      ->toArray($entity));
    if ($this->configuration['include_translations']) {
      foreach ($entity
        ->getTranslationLanguages(FALSE) as $language) {
        (yield $this
          ->toArray($entity
          ->getTranslation($language
          ->getId())));
      }
    }
  }
}