fix: prevent null reference errors
This commit is contained in:
@@ -46,6 +46,10 @@ class TravelController extends AbstractController
|
|||||||
{
|
{
|
||||||
$travel = $this->loadCached($travelId, $hotelId);
|
$travel = $this->loadCached($travelId, $hotelId);
|
||||||
|
|
||||||
|
if (null === $travel) {
|
||||||
|
return new JsonResponse(['message' => 'Not found'], Response::HTTP_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->json($travel, Response::HTTP_OK, [], ['groups' => ['api:list', 'api:single']]);
|
return $this->json($travel, Response::HTTP_OK, [], ['groups' => ['api:list', 'api:single']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +72,10 @@ class TravelController extends AbstractController
|
|||||||
|
|
||||||
$travel = $this->loadCached($travelId, $hotelId);
|
$travel = $this->loadCached($travelId, $hotelId);
|
||||||
|
|
||||||
|
if (null === $travel) {
|
||||||
|
return new JsonResponse(['message' => 'Not found'], Response::HTTP_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->json($travel, Response::HTTP_OK, [], ['groups' => ['api:list', 'api:single']]);
|
return $this->json($travel, Response::HTTP_OK, [], ['groups' => ['api:list', 'api:single']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +90,7 @@ class TravelController extends AbstractController
|
|||||||
$travel = $this->travelXmlLoader->loadById($travelId, $hotelId);
|
$travel = $this->travelXmlLoader->loadById($travelId, $hotelId);
|
||||||
|
|
||||||
if (null === $travel) {
|
if (null === $travel) {
|
||||||
return new JsonResponse(['message' => 'Not found'], Response::HTTP_NOT_FOUND);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pickupXmlLoader->patchPickupsDetails($travel);
|
$this->pickupXmlLoader->patchPickupsDetails($travel);
|
||||||
|
|||||||
Reference in New Issue
Block a user