Example #1
0
 /**
  * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity
  *
  * @return string
  */
 protected function createAddVoucherCodeButton(SpyDiscount $discountEntity)
 {
     if ($discountEntity->getFkDiscountVoucherPool()) {
         $addVoucherCodeDiscountUrl = Url::generate('/discount/index/edit', [self::URL_PARAM_ID_DISCOUNT => $discountEntity->getIdDiscount()]);
         return $this->generateCreateButton($addVoucherCodeDiscountUrl, 'Add code');
     }
     return '';
 }
 /**
  * @param integer $idDiscount
  * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity
  * @param \Generated\Shared\Transfer\DiscountConfiguratorTransfer $discountConfigurator
  *
  * @return void
  */
 protected function hydrateDiscountVoucher($idDiscount, SpyDiscount $discountEntity, DiscountConfiguratorTransfer $discountConfigurator)
 {
     if ($discountEntity->getFkDiscountVoucherPool()) {
         $discountVoucherTransfer = new DiscountVoucherTransfer();
         $discountVoucherTransfer->setIdDiscount($idDiscount);
         $discountVoucherTransfer->setFkDiscountVoucherPool($discountEntity->getFkDiscountVoucherPool());
         $discountConfigurator->setDiscountVoucher($discountVoucherTransfer);
     }
 }
 /**
  * @param string $voucherCode
  * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity
  *
  * @return \Orm\Zed\Discount\Persistence\SpyDiscountVoucher
  */
 protected function createVoucherCode($voucherCode, SpyDiscount $discountEntity)
 {
     $voucherEntity = new SpyDiscountVoucher();
     $voucherEntity->setFkDiscountVoucherPool($discountEntity->getFkDiscountVoucherPool());
     $voucherEntity->setCode($voucherCode);
     $voucherEntity->setIsActive(true);
     $voucherEntity->save();
     return $voucherEntity;
 }