bookingRepository->findOneBy(['uuid' => $uuid]); if (null === $booking) { return new JsonResponse(['message' => 'Not found'], Response::HTTP_NOT_FOUND); } return $this->bookingResponse($booking); } #[Route(path: '/accommodation-bookings/{uuid}/accept', name: 'api_accommodation_bookings_accept', methods: ['POST'])] public function accept(string $uuid): JsonResponse { $booking = $this->bookingRepository->findOneBy(['uuid' => $uuid]); if (null === $booking) { return new JsonResponse(['message' => 'Not found'], Response::HTTP_NOT_FOUND); } $this->bookingService->acceptBooking($booking); return $this->bookingResponse($booking); } private function bookingResponse(AccommodationBooking $booking): JsonResponse { $response = new AccommodationBookingApiResponse($booking, $this->breakdownCalculator->compute($booking)); $json = $this->serializer->serialize($response, 'json', ['groups' => ['api:single']]); return new JsonResponse($json, Response::HTTP_OK, [], true); } }