function FieldInstancePerViewMode::initializeIterator

Same name in this branch
  1. 11.x core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
Same name in other branches
  1. 9 core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  2. 9 core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()
  3. 8.9.x core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  4. 8.9.x core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()
  5. 10 core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  6. 10 core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()

Overrides FieldInstance::initializeIterator

File

core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php, line 24

Class

FieldInstancePerViewMode
Drupal 7 field instance per view mode source class.

Namespace

Drupal\field\Plugin\migrate\source\d7

Code

protected function initializeIterator() {
    $instances = parent::initializeIterator();
    $rows = [];
    foreach ($instances->getArrayCopy() as $instance) {
        $data = unserialize($instance['data']);
        foreach ($data['display'] as $view_mode => $formatter) {
            $rows[] = array_merge($instance, [
                'view_mode' => $view_mode,
                'formatter' => $formatter,
            ]);
        }
    }
    return new \ArrayIterator($rows);
}

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