checkMandatoryFields($command); $type = $command->getField('type') ?: Entities::APPOINTMENT; /** @var ReservationServiceInterface $reservationService */ $reservationService = $this->container->get('application.reservation.service')->get($type); /** @var Appointment|Event $reservation */ $reservation = $reservationService->getReservationByBookingId((int)$command->getArg('id')); /** @var CustomerBooking $booking */ $booking = $reservation->getBookings()->getItem( (int)$command->getArg('id') ); if (!$booking instanceof CustomerBooking) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not retrieve booking'); return $result; } $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully get booking'); $result->setData([ 'type' => $type, $type => $reservation->toArray(), Entities::BOOKING => $booking->toArray(), 'appointmentStatusChanged' => $command->getFields()['appointmentStatusChanged'] ]); return $result; } }