checkMandatoryFields($command); $result = new CommandResult(); $type = $command->getField('type') ?: Entities::APPOINTMENT; /** @var ReservationServiceInterface $reservationService */ $reservationService = $this->container->get('application.reservation.service')->get($type); /** @var SettingsService $settingsService */ $settingsService = $this->container->get('domain.settings.service'); $status = BookingStatus::CANCELED; try { $bookingData = $reservationService->updateStatus( (int)$command->getArg('id'), $status, $command->getField('token') ); $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully updated booking status'); $result->setData(array_merge( $bookingData, [ 'type' => $type, 'status' => $status, 'message' => BackendStrings::getAppointmentStrings()['appointment_status_changed'] . $status ] )); } catch (BookingCancellationException $e) { $result->setResult(CommandResult::RESULT_ERROR); } $notificationSettings = $settingsService->getCategorySettings('notifications'); if ($notificationSettings['cancelSuccessUrl'] && $result->getResult() === CommandResult::RESULT_SUCCESS) { $result->setUrl($notificationSettings['cancelSuccessUrl']); } elseif ($notificationSettings['cancelErrorUrl'] && $result->getResult() === CommandResult::RESULT_ERROR) { $result->setUrl($notificationSettings['cancelErrorUrl']); } else { $result->setUrl('/'); } return $result; } }