You are here

public function TaxonomyTerm::getYield in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/csv_example/src/Plugin/migrate/source/TaxonomyTerm.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\TaxonomyTerm::getYield()
  2. 3.0.x modules/csv_example/src/Plugin/migrate/source/TaxonomyTerm.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\TaxonomyTerm::getYield()

Prepare one row per taxonomy term field in the source.

@codingStandardsIgnoreStart

@codingStandardsIgnoreEnd

Parameters

\Generator $file: The source data.

Return value

\Generator A new row, one for each filename in the source image column.

1 call to TaxonomyTerm::getYield()
TaxonomyTerm::initializeIterator in modules/csv_example/src/Plugin/migrate/source/TaxonomyTerm.php

File

modules/csv_example/src/Plugin/migrate/source/TaxonomyTerm.php, line 41

Class

TaxonomyTerm
Yields each taxonomy vocabulary and term pair.

Namespace

Drupal\commerce_migrate_csv_example\Plugin\migrate\source

Code

public function getYield(\Generator $file) {
  foreach ($file as $row) {
    $new_row = [];
    for ($i = 1; $i < 4; $i++) {
      $new_row['vocabulary_name'] = trim($row["vocabulary_name{$i}"]);
      $new_row['term'] = trim($row["term{$i}"]);
      if (!empty($new_row['vocabulary_name']) && !empty($new_row['term'])) {
        if ($this
          ->rowUnique($new_row)) {
          (yield $new_row);
        }
      }
    }
  }
}