function FieldInstance::initializeIterator

Same name in other branches
  1. 9 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::initializeIterator()
  2. 8.9.x core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::initializeIterator()
  3. 11.x core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::initializeIterator()

Overrides SqlBase::initializeIterator

2 calls to 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.
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 97

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.