You are here

class ProductVideo in Commerce Migrate 3.1.x

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

Yields values for product video paragraph.

There are three for product videos in the example source. Currently, just one is retrieved and sent to the process pipeline. See import_product_video.

Plugin annotation


@MigrateSource(
  id = "csv_example_product_video"
)

Hierarchy

  • class \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\ProductVideo extends \Drupal\migrate_source_csv\Plugin\migrate\source\CSV

Expanded class hierarchy of ProductVideo

File

modules/csv_example/src/Plugin/migrate/source/ProductVideo.php, line 17

Namespace

Drupal\commerce_migrate_csv_example\Plugin\migrate\source
View source
class ProductVideo extends CSV {

  /**
   * {@inheritdoc}
   */
  public function initializeIterator() {
    $file = parent::initializeIterator();
    return $this
      ->getYield($file);
  }

  /**
   * Prepare one row per product video paragraph entity 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) {
      if (!empty($row['video1']) && !empty($row['thumbnail1'])) {
        (yield $row);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProductVideo::getYield public function Prepare one row per product video paragraph entity in the source row.
ProductVideo::initializeIterator public function