Beispiel #1
0
 /**
  * Call the Model and delegate the create or delete action
  * Feed the Event with the updated model
  *
  * @param CouponModel               $coupon Model to save
  * @param CouponCreateOrUpdateEvent $event  Event containing data
  * @param EventDispatcherInterface $dispatcher
  */
 protected function createOrUpdate(CouponModel $coupon, CouponCreateOrUpdateEvent $event, EventDispatcherInterface $dispatcher)
 {
     $coupon->setDispatcher($dispatcher);
     // Set default condition if none found
     /** @var ConditionInterface $noConditionRule */
     $noConditionRule = $this->noConditionRule;
     /** @var ConditionFactory $conditionFactory */
     $conditionFactory = $this->conditionFactory;
     $couponRuleCollection = new ConditionCollection();
     $couponRuleCollection[] = $noConditionRule;
     $defaultSerializedRule = $conditionFactory->serializeConditionCollection($couponRuleCollection);
     $coupon->createOrUpdate($event->getCode(), $event->getTitle(), $event->getEffects(), $event->getServiceId(), $event->isRemovingPostage(), $event->getShortDescription(), $event->getDescription(), $event->isEnabled(), $event->getExpirationDate(), $event->isAvailableOnSpecialOffers(), $event->isCumulative(), $event->getMaxUsage(), $defaultSerializedRule, $event->getLocale(), $event->getFreeShippingForCountries(), $event->getFreeShippingForMethods(), $event->getPerCustomerUsageCount(), $event->getStartDate());
     $event->setCouponModel($coupon);
 }