You are here

protected function CSV::getGenerator in Migrate Source CSV 8.3

Get the generator.

@codingStandardsIgnoreStart

@codingStandardsIgnoreEnd

Parameters

\Iterator $records: The CSV records.

Return value

\Generator The records generator.

1 call to CSV::getGenerator()
CSV::initializeIterator in src/Plugin/migrate/source/CSV.php

File

src/Plugin/migrate/source/CSV.php, line 242

Class

CSV
Source for CSV files.

Namespace

Drupal\migrate_source_csv\Plugin\migrate\source

Code

protected function getGenerator(\Iterator $records) {
  $record_num = $this->configuration['header_offset'] ?? 0;
  foreach ($records as $record) {
    if ($this->configuration['create_record_number']) {
      $record[$this->configuration['record_number_field']] = ++$record_num;
    }
    (yield $record);
  }
}