コード例 #1
0
 /**
  * @param Event $event
  * @param User $user
  * @param boolean $isStudent
  * @param DiscountCoupon $coupon
  * @return Attendee
  */
 public function create(Event $event, User $user, $isStudent = false, $registrationType = Attendee::TALKS_ONLY, DiscountCoupon $coupon = null)
 {
     if ($this->hasAnActiveRegistration($event, $user)) {
         throw new InvalidArgumentException('Você já possui uma inscrição neste evento');
     }
     $attendee = $this->attendeeFactory->create($event, $user, $isStudent, $registrationType);
     if ($coupon) {
         $attendee->applyDiscount($coupon);
     }
     $this->repository->append($attendee);
     $message = $this->deliveryService->getMessageFromTemplate($isStudent ? 'StudentRegistration' : 'Registration', array('user_name' => $user->getName(), 'event_name' => $event->getName(), 'event_location' => $event->getLocation()->getName()));
     $message->setTo($user->getEmail());
     $this->deliveryService->send($message);
     return $attendee;
 }