You are here

protected function ContentExporter::processPromotion in Commerce Demo 8.2

Same name and namespace in other branches
  1. 8 src/ContentExporter.php \Drupal\commerce_demo\ContentExporter::processPromotion()

Processes the exported promotion.

Parameters

array $export: The export array.

\Drupal\commerce_promotion\Entity\PromotionInterface $promotion: The promotion.

Return value

array The processed export array.

1 call to ContentExporter::processPromotion()
ContentExporter::export in src/ContentExporter.php
Exports the given entity.

File

src/ContentExporter.php, line 261

Class

ContentExporter
Defines the content exporter.

Namespace

Drupal\commerce_demo

Code

protected function processPromotion(array $export, PromotionInterface $promotion) {

  // Export the coupons as well.
  $coupons = [];
  foreach ($promotion
    ->getCoupons() as $coupon) {
    $coupons[$coupon
      ->uuid()] = $this
      ->export($coupon);

    // The array is keyed by UUID, no need to have it in the export too.
    unset($coupons[$coupon
      ->uuid()]['uuid']);
  }
  $export['coupons'] = $coupons;
  return $export;
}