You are here

public function Spreadsheet::initializeIterator in Migrate Spreadsheet 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/migrate/source/Spreadsheet.php \Drupal\migrate_spreadsheet\Plugin\migrate\source\Spreadsheet::initializeIterator()

Initializes the iterator with the source data.

Return value

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

Overrides SourcePluginBase::initializeIterator

1 call to Spreadsheet::initializeIterator()
Spreadsheet::fields in src/Plugin/migrate/source/Spreadsheet.php
Returns available fields on the source.

File

src/Plugin/migrate/source/Spreadsheet.php, line 167

Class

Spreadsheet
Provides a source plugin that migrate from spreadsheet files.

Namespace

Drupal\migrate_spreadsheet\Plugin\migrate\source

Code

public function initializeIterator() : SpreadsheetIteratorInterface {
  if (!$this->iteratorIsInitialized) {
    $configuration = $this
      ->getConfiguration();
    $configuration['worksheet'] = $this
      ->loadWorksheet();
    $configuration['keys'] = array_keys($configuration['keys']);

    // The 'file' and 'plugin' items are not part of iterator configuration.
    unset($configuration['file'], $configuration['plugin']);
    $this->spreadsheetIterator
      ->setConfiguration($configuration);

    // Flag that the iterator has been initialized.
    $this->iteratorIsInitialized = TRUE;
  }
  return $this->spreadsheetIterator;
}