You are here

protected function ViewMode::initializeIterator in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php \Drupal\node\Plugin\migrate\source\d6\ViewMode::initializeIterator()
  2. 8 core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php \Drupal\field\Plugin\migrate\source\d7\ViewMode::initializeIterator()
Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php \Drupal\field\Plugin\migrate\source\d7\ViewMode::initializeIterator()

Implementation of MigrateSource::performRewind().

We could simply execute the query and be functionally correct, but we will take advantage of the PDO-based API to optimize the query up-front.

Overrides SqlBase::initializeIterator

File

core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php, line 22
Contains \Drupal\field\Plugin\migrate\source\d7\ViewMode.

Class

ViewMode
Plugin annotation @MigrateSource( id = "d7_view_mode" )

Namespace

Drupal\field\Plugin\migrate\source\d7

Code

protected function initializeIterator() {
  $rows = [];
  $result = $this
    ->prepareQuery()
    ->execute();
  foreach ($result as $field_instance) {
    $data = unserialize($field_instance['data']);
    foreach (array_keys($data['display']) as $view_mode) {
      $key = $field_instance['entity_type'] . '.' . $view_mode;
      $rows[$key] = [
        'entity_type' => $field_instance['entity_type'],
        'view_mode' => $view_mode,
      ];
    }
  }
  return new \ArrayIterator($rows);
}