Exemplo n.º 1
0
 /**
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var Event $eventZFDays, $eventPHPDay */
     $eventZFDays = $manager->merge($this->getReference('event-zfday'));
     $eventPHPDay = $manager->merge($this->getReference('event-phpday'));
     // Promo code 1
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for ZFDays')->setCode('Promo code for ZFDays')->setEvent($eventZFDays);
     $manager->persist($promoCode);
     $this->addReference('promoCode-1', $promoCode);
     // Promo code 2
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for ZFDays 5%')->setCode('Promo code for ZFDays 5%')->setDiscountAmount(5)->setEvent($eventZFDays);
     $manager->persist($promoCode);
     $this->addReference('promoCode-2', $promoCode);
     // Promo code 3
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for ZFDays overdue')->setCode('Promo code for ZFDays overdue')->setEvent($eventZFDays)->setEndDate(new \DateTime('-11 Days'));
     $manager->persist($promoCode);
     $this->addReference('promoCode-3', $promoCode);
     // Promo code 4
     $promoCode = new PromoCode();
     $promoCode->setTitle('Promo code for PHPDay')->setCode('Promo code for PHPDay')->setEvent($eventPHPDay);
     $manager->persist($promoCode);
     $this->addReference('promoCode-4', $promoCode);
     $manager->flush();
 }
Exemplo n.º 2
0
 /**
  * @param \Stfalcon\Bundle\EventBundle\Entity\PromoCode $promoCode
  */
 public function setPromoCode($promoCode)
 {
     $this->setHasDiscount(true);
     $amountWithDiscount = $this->amountWithoutDiscount - $this->amountWithoutDiscount * ($promoCode->getDiscountAmount() / 100);
     $this->setAmount($amountWithDiscount);
     $this->promoCode = $promoCode;
 }