public function ProductCta::getYield in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x modules/csv_example/src/Plugin/migrate/source/ProductCta.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\ProductCta::getYield()
- 3.0.x modules/csv_example/src/Plugin/migrate/source/ProductCta.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\ProductCta::getYield()
Prepare one row per CTA paragraph in the source row.
@codingStandardsIgnoreStart
@codingStandardsIgnoreEnd
Parameters
\Generator $file: The source CSV file object.
Return value
\Generator A new row, one for each CTA paragraph field.
1 call to ProductCta::getYield()
- ProductCta::initializeIterator in modules/
csv_example/ src/ Plugin/ migrate/ source/ ProductCta.php
File
- modules/
csv_example/ src/ Plugin/ migrate/ source/ ProductCta.php, line 41
Class
- ProductCta
- Yields values for each product CTA paragraph.
Namespace
Drupal\commerce_migrate_csv_example\Plugin\migrate\sourceCode
public function getYield(\Generator $file) {
foreach ($file as $row) {
for ($i = 1; $i < 3; $i++) {
if (!empty($row["cta_title{$i}"]) || !empty($row["cta_link{$i}"]) || !empty($row["cta_image{$i}"])) {
$new_row = $row;
$new_row['cta_title'] = trim($row["cta_title{$i}"]);
$new_row['cta_link'] = trim($row["cta_link{$i}"]);
$new_row['cta_image'] = trim($row["cta_image{$i}"]);
(yield $new_row);
}
}
}
}