You are here

protected function FieldInstancePerViewMode::initializeIterator in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  2. 8 core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()
Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::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/FieldInstancePerViewMode.php, line 25
Contains \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode.

Class

FieldInstancePerViewMode
The field instance per view mode source class.

Namespace

Drupal\field\Plugin\migrate\source\d7

Code

protected function initializeIterator() {
  $rows = array();
  $result = $this
    ->prepareQuery()
    ->execute();
  foreach ($result as $field_instance) {
    $data = unserialize($field_instance['data']);

    // We don't need to include the serialized data in the returned rows.
    unset($field_instance['data']);
    foreach ($data['display'] as $view_mode => $info) {
      $rows[] = array_merge($field_instance, $info, array(
        'view_mode' => $view_mode,
      ));
    }
  }
  return new \ArrayIterator($rows);
}