You are here

protected function ViewMode::initializeIterator in Commerce Migrate 3.1.x

Same name in this branch
  1. 3.1.x modules/ubercart/src/Plugin/migrate/source/uc7/ViewMode.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc7\ViewMode::initializeIterator()
  2. 3.1.x modules/ubercart/src/Plugin/migrate/source/uc6/ViewMode.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc6\ViewMode::initializeIterator()
  3. 3.1.x modules/commerce/src/Plugin/migrate/source/commerce1/ViewMode.php \Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\ViewMode::initializeIterator()
Same name and namespace in other branches
  1. 8.2 modules/ubercart/src/Plugin/migrate/source/uc7/ViewMode.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc7\ViewMode::initializeIterator()
  2. 3.0.x modules/ubercart/src/Plugin/migrate/source/uc7/ViewMode.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc7\ViewMode::initializeIterator()

Initializes the iterator with the source data.

Return value

\Iterator Returns an iterable object of data for this source.

Overrides ViewMode::initializeIterator

File

modules/ubercart/src/Plugin/migrate/source/uc7/ViewMode.php, line 23

Class

ViewMode
The view mode source class.

Namespace

Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc7

Code

protected function initializeIterator() {
  $instances = FieldInstance::initializeIterator();
  $this->productTypes = $this
    ->getProductTypes();
  $rows = [];
  foreach ($instances
    ->getArrayCopy() as $instance) {
    $data = unserialize($instance['data']);
    foreach (array_keys($data['display']) as $view_mode) {
      $key = $instance['entity_type'] . '.' . $view_mode;
      if (in_array($instance['bundle'], $this->productTypes)) {
        $key = 'commerce_product .' . $view_mode;
        $instance['entity_type'] = 'commerce_product';
      }
      $rows[$key] = array_merge($instance, [
        'view_mode' => $view_mode,
      ]);
    }
  }
  return new \ArrayIterator($rows);
}