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/node/src/Plugin/migrate/source/d6/ViewMode.php \Drupal\node\Plugin\migrate\source\d6\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/node/src/Plugin/migrate/source/d6/ViewMode.php, line 23
Contains \Drupal\node\Plugin\migrate\source\d6\ViewMode.

Class

ViewMode
The view mode source.

Namespace

Drupal\node\Plugin\migrate\source\d6

Code

protected function initializeIterator() {
  $rows = array();
  $result = $this
    ->prepareQuery()
    ->execute();
  while ($field_row = $result
    ->fetchAssoc()) {
    $field_row['display_settings'] = unserialize($field_row['display_settings']);
    foreach ($this
      ->getViewModes() as $view_mode) {
      if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
        if (!isset($rows[$view_mode])) {
          $rows[$view_mode]['entity_type'] = 'node';
          $rows[$view_mode]['view_mode'] = $view_mode;
        }
      }
    }
  }
  return new \ArrayIterator($rows);
}