class ProductTab in Commerce Migrate 3.1.x
Same name and namespace in other branches
- 8.2 modules/csv_example/src/Plugin/migrate/source/ProductTab.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\ProductTab
- 3.0.x modules/csv_example/src/Plugin/migrate/source/ProductTab.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\ProductTab
Yields values for each product tab paragraph.
There are two set of columns for the paragraph product tab in each row of the example source. Create a new row for each set where at least one value of the set is non empty.See import_tab for the column names.
Plugin annotation
@MigrateSource(
id = "csv_example_product_tab"
)
Hierarchy
- class \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\ProductTab extends \Drupal\migrate_source_csv\Plugin\migrate\source\CSV
Expanded class hierarchy of ProductTab
File
- modules/
csv_example/ src/ Plugin/ migrate/ source/ ProductTab.php, line 18
Namespace
Drupal\commerce_migrate_csv_example\Plugin\migrate\sourceView source
class ProductTab extends CSV {
/**
* {@inheritdoc}
*/
public function initializeIterator() {
$file = parent::initializeIterator();
return $this
->getYield($file);
}
/**
* Prepares one row per tab paragraph values in the source row.
*
* @param \Generator $file
* The source CSV file object.
*
* @codingStandardsIgnoreStart
*
* @return \Generator
* A new row, one for each filename in the source image column.
*
* @codingStandardsIgnoreEnd
*/
public function getYield(\Generator $file) {
foreach ($file as $row) {
for ($i = 1; $i < 3; $i++) {
if (!empty($row["tab_title{$i}"]) || !empty($row["tab_content{$i}"]) || !empty($row["tab_content{$i}"])) {
$new_row = $row;
$new_row['tab_title'] = trim($row["tab_title{$i}"]);
$new_row['tab_content'] = trim($row["tab_content{$i}"]);
$new_row['tab_cta'] = trim($row["tab_cta{$i}"]);
(yield $new_row);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProductTab:: |
public | function | Prepares one row per tab paragraph values in the source row. | |
ProductTab:: |
public | function |