function ViewMode::initializeIterator

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

Overrides FieldInstance::initializeIterator

File

core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php, line 18

Class

ViewMode
The 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 (array_keys($data['display']) as $view_mode) {
            $key = $instance['entity_type'] . '.' . $view_mode;
            $rows[$key] = array_merge($instance, [
                'view_mode' => $view_mode,
            ]);
        }
    }
    return new \ArrayIterator($rows);
}

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