/**
  * Edit contact
  *
  * @param Contact $contact
  * @param Reservation $reservation
  * @throws InvalidSourceException
  * @ignorevalidation $contact
  * @ignorevalidation $reservation
  */
 public function editAction(Contact $contact, Reservation $reservation)
 {
     if ($reservation->getContact() !== $contact) {
         throw new InvalidSourceException('Can not edit contact uid ' . $contact->getUid() . '. Contact not found in Reservation uid: ' . $reservation->getUid() . '.', 1460039887);
     }
     $this->view->assign('contact', $contact);
 }
 /**
  * action removeParticipant
  *
  * @param Reservation $reservation
  * @param Person $participant
  * @param string $reason Reason for cancellation of reservation for this participant. Allowed:  'byOrganizer', 'withCosts', 'withoutCost'
  * @return void
  */
 public function removeParticipantAction(Reservation $reservation, Person $participant, $reason)
 {
     $reservation->removeParticipant($participant);
     $reservation->getLesson()->removeParticipant($participant);
     $this->personRepository->remove($participant);
     $this->addFlashMessage($this->translate('message.reservation.removeParticipant.success'));
     if ($this->settings['bookings']['removeParticipant'][$reason]['confirm']['sendNotification']) {
         /**@var Notification $notification * */
         $notification = $this->objectManager->get(Notification::class);
         $bodytext = $this->notificationService->render($this->settings['bookings']['removeParticipant'][$reason]['confirm']['templateFileName'], 'html', 'Bookings/Email/RemoveParticipant', ['reservation' => $reservation, 'participant' => $participant, 'reason' => $reason, 'baseUrl' => $this->getBaseUrlForFrontend()]);
         $notification->setRecipient($reservation->getContact()->getEmail());
         $notification->setBodytext($bodytext);
         $notification->setSubject($this->settings['bookings']['removeParticipant'][$reason]['confirm']['subject']);
         $notification->setSender($this->settings['bookings']['removeParticipant'][$reason]['confirm']['fromEmail']);
         $notification->setReservation($reservation);
         $notificationSuccess = $this->notificationService->send($notification);
         if ($notificationSuccess) {
             $mailMessageKey = 'message.bookings.cancel.sendNotification.success';
             $mailMessageSeverity = AbstractMessage::OK;
             $notification->setSentAt(new \DateTime());
         } else {
             $mailMessageKey = 'message.bookings.cancel.sendNotification.error';
             $mailMessageSeverity = AbstractMessage::WARNING;
         }
         $this->notificationRepository->add($notification);
         $this->persistenceManager->persistAll();
         $reservation->addNotification($notification);
         $this->addFlashMessage($this->translate($mailMessageKey), null, $mailMessageSeverity);
     }
     $this->redirect('edit', null, null, ['reservation' => $reservation]);
 }
 /**
  * @test
  */
 public function getContactReturnsInitialValueForPerson()
 {
     $this->assertEquals(NULL, $this->subject->getContact());
 }
 /**
  * action delete
  *
  * @param Reservation $reservation
  * @return void
  */
 public function deleteAction(Reservation $reservation)
 {
     $this->addFlashMessage($this->translate('message.reservation.delete.success'));
     if ($participants = $reservation->getParticipants()) {
         foreach ($participants as $participant) {
             $this->personRepository->remove($participant);
         }
     }
     if ($company = $reservation->getCompany()) {
         $this->companyRepository->remove($company);
     }
     if ($contact = $reservation->getContact()) {
         $this->contactRepository->remove($contact);
     }
     $this->reservationRepository->remove($reservation);
     $this->session->clean();
 }