getContainer()->getPermissionsService()->currentUserCanWriteStatus(Entities::APPOINTMENTS)) { throw new AccessDeniedException('You are not allowed to update booking status'); } $result = new CommandResult(); $type = $command->getField('type') ?: Entities::APPOINTMENT; /** @var ReservationServiceInterface $reservationService */ $reservationService = $this->container->get('application.reservation.service')->get($type); try { $bookingData = $reservationService->updateStatus( (int)$command->getArg('id'), BookingStatus::CANCELED, null ); $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully updated booking status'); $result->setData(array_merge( $bookingData, [ 'type' => $type, 'status' => BookingStatus::CANCELED, 'message' => BackendStrings::getAppointmentStrings()['appointment_status_changed'] . BookingStatus::CANCELED ] )); } catch (BookingCancellationException $e) { throw new AccessDeniedException('Appointment can\'t be canceled'); } return $result; } }