/**
  * Edit participant
  *
  * @param Person $participant
  * @param Reservation $reservation
  * @throws InvalidSourceException
  */
 public function editAction(Person $participant, Reservation $reservation)
 {
     if (!$reservation->getParticipants()->contains($participant)) {
         throw new InvalidSourceException('Can not edit participant uid ' . $participant->getUid() . '. Participant not found in Reservation uid: ' . $participant->getReservation()->getUid() . '.', 1459343264);
     }
     $this->view->assign('participant', $participant);
 }
 /**
  * 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) {
             $reservation->getLesson()->removeParticipant($participant);
             $this->personRepository->remove($participant);
         }
     }
     if ($company = $reservation->getCompany()) {
         $this->companyRepository->remove($company);
     }
     if ($contact = $reservation->getContact()) {
         $this->personRepository->remove($contact);
     }
     $this->reservationRepository->remove($reservation);
     $this->redirect('list');
 }
 /**
  * @test
  */
 public function getParticipantsReturnsInitialValueForPerson()
 {
     $newObjectStorage = new ObjectStorage();
     $this->assertEquals($newObjectStorage, $this->subject->getParticipants());
 }
 /**
  * action newParticipant
  *
  * @param Reservation $reservation
  * @param Person $newParticipant
  * @ignorevalidation $newParticipant
  * @return void
  */
 public function newParticipantAction(Reservation $reservation, Person $newParticipant = null)
 {
     if (!($reservation->getStatus() === Reservation::STATUS_DRAFT || $reservation->getStatus() === Reservation::STATUS_NEW)) {
         $this->denyAccess();
         return;
     }
     if (!$reservation->getStatus() == Reservation::STATUS_DRAFT) {
         $reservation->setStatus(Reservation::STATUS_DRAFT);
     }
     $lesson = $reservation->getLesson();
     if ($lesson instanceof BookableInterface && $lesson->getFreePlaces() < 1) {
         $this->addFlashMessage($this->translate('message.noFreePlacesForThisLesson'), '', AbstractMessage::ERROR, true);
     } elseif (!count($reservation->getParticipants())) {
         $this->addFlashMessage($this->translate('message.reservation.newParticipant.addAtLeastOneParticipant'), '', AbstractMessage::NOTICE);
     }
     if ($this->request->getOriginalRequest() instanceof \TYPO3\CMS\Extbase\Mvc\Request) {
         $newParticipant = $this->request->getOriginalRequest()->getArgument('newParticipant');
     }
     $this->view->assignMultiple(['newParticipant' => $newParticipant, 'reservation' => $reservation]);
 }