Exemple #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
  */
 protected function createOrUpdateCondition(CouponModel $coupon, CouponCreateOrUpdateEvent $event)
 {
     $coupon->setDispatcher($event->getDispatcher());
     /** @var ConditionFactory $conditionFactory */
     $conditionFactory = $this->conditionFactory;
     $coupon->createOrUpdateConditions($conditionFactory->serializeConditionCollection($event->getConditions()), $event->getLocale());
     $event->setCouponModel($coupon);
 }
 /**
  * Manage how a Condition is updated
  *
  * @param Coupon              $coupon     Coupon Model
  * @param ConditionCollection $conditions Condition collection
  */
 protected function manageConditionUpdate(Coupon $coupon, ConditionCollection $conditions)
 {
     $couponEvent = new CouponCreateOrUpdateEvent($coupon->getCode(), $coupon->getType(), $coupon->getTitle(), $coupon->getEffects(), $coupon->getShortDescription(), $coupon->getDescription(), $coupon->getIsEnabled(), $coupon->getExpirationDate(), $coupon->getIsAvailableOnSpecialOffers(), $coupon->getIsCumulative(), $coupon->getIsRemovingPostage(), $coupon->getMaxUsage(), $coupon->getLocale(), $coupon->getFreeShippingForCountries(), $coupon->getFreeShippingForModules(), $coupon->getPerCustomerUsageCount());
     $couponEvent->setCouponModel($coupon);
     $couponEvent->setConditions($conditions);
     $eventToDispatch = TheliaEvents::COUPON_CONDITION_UPDATE;
     // Dispatch Event to the Action
     $this->dispatch($eventToDispatch, $couponEvent);
     $this->adminLogAppend(AdminResources::COUPON, AccessManager::UPDATE, sprintf('Coupon %s (ID %s) conditions updated', $couponEvent->getCouponModel()->getTitle(), $couponEvent->getCouponModel()->getType()), $couponEvent->getCouponModel()->getId());
 }