You are here

protected function FieldInstance::initializeIterator in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::initializeIterator()
  2. 9 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::initializeIterator()

Initializes the iterator with the source data.

Return value

\Iterator Returns an iterable object of data for this source.

Overrides SqlBase::initializeIterator

1 call to FieldInstance::initializeIterator()
FieldInstance::doCount in core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
Gets the source count using countQuery().
2 methods override FieldInstance::initializeIterator()
FieldInstancePerViewMode::initializeIterator in core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php
Initializes the iterator with the source data.
ViewMode::initializeIterator in core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php
Initializes the iterator with the source data.

File

core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php, line 95

Class

FieldInstance
Drupal 7 field instances source from database.

Namespace

Drupal\field\Plugin\migrate\source\d7

Code

protected function initializeIterator() {
  $results = $this
    ->prepareQuery()
    ->execute()
    ->fetchAll();

  // Group all instances by their base field.
  $instances = [];
  foreach ($results as $result) {
    $instances[$result['field_id']][] = $result;
  }

  // Add the array of all instances using the same base field to each row.
  $rows = [];
  foreach ($results as $result) {
    $result['instances'] = $instances[$result['field_id']];
    $rows[] = $result;
  }
  return new \ArrayIterator($rows);
}