/** * 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 create * * @param Reservation $newReservation * @return void */ public function createAction(Reservation $newReservation) { if (!is_null($newReservation->getUid()) || $this->session instanceof SessionInterface && $this->session->has(self::SESSION_IDENTIFIER_RESERVATION)) { $this->denyAccess(); return; } if ($contact = $newReservation->getContact()) { $contact->setReservation($newReservation); } $newReservation->setStatus(Reservation::STATUS_DRAFT); if ($newReservation->getContactIsParticipant() && is_object($contact)) { $participant = new Person(); foreach (ObjectAccess::getGettableProperties($contact) as $propertyName => $propertyValue) { if (ObjectAccess::isPropertySettable($participant, $propertyName)) { ObjectAccess::setProperty($participant, $propertyName, $propertyValue); } } $participant->setType(Person::PERSON_TYPE_PARTICIPANT); $newReservation->addParticipant($participant); $newReservation->getLesson()->addParticipant($participant); } $this->addFlashMessage($this->translate('message.reservation.create.success')); $this->reservationRepository->add($newReservation); $this->persistenceManager->persistAll(); $this->session->set(self::SESSION_IDENTIFIER_RESERVATION, $newReservation->getUid()); $this->redirect('edit', null, null, ['reservation' => $newReservation]); }