Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContentEntity.php

function 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())));
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal