Procházet zdrojové kódy

fix vessel creation

master
Daniel před 11 měsíci
rodič
revize
24b1d19493
2 změnil soubory, kde provedl 6 přidání a 8 odebrání
  1. +4
    -6
      httpdocs/src/Mapper/UserTripApiToEntityMapper.php
  2. +2
    -2
      httpdocs/src/Mapper/VesselApiToEntityMapper.php

+ 4
- 6
httpdocs/src/Mapper/UserTripApiToEntityMapper.php Zobrazit soubor

@@ -19,6 +19,8 @@ class UserTripApiToEntityMapper implements MapperInterface
{ {
public function __construct( public function __construct(
private UserTripRepository $repository, private UserTripRepository $repository,
private TripRepository $tripRepository,
private UserRepository $userRepository,
private MediaObjectRepository $mediaObjectRepository, private MediaObjectRepository $mediaObjectRepository,
private MicroMapperInterface $microMapper private MicroMapperInterface $microMapper
) { ) {
@@ -42,16 +44,12 @@ class UserTripApiToEntityMapper implements MapperInterface
throw new \Exception('Trip and User are required for new user trips'); throw new \Exception('Trip and User are required for new user trips');
} }


$trip = $this->microMapper->map($dto->tripIri, Trip::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$trip = $this->tripRepository->find($dto->tripIri->id);
if (!$trip) { if (!$trip) {
throw new \Exception('Trip not found'); throw new \Exception('Trip not found');
} }


$user = $this->microMapper->map($dto->userIri, User::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$user = $this->userRepository->find($dto->userIri->id);
if (!$user) { if (!$user) {
throw new \Exception('User not found'); throw new \Exception('User not found');
} }


+ 2
- 2
httpdocs/src/Mapper/VesselApiToEntityMapper.php Zobrazit soubor

@@ -33,11 +33,11 @@ class VesselApiToEntityMapper implements MapperInterface
} }


// For new vessels, we need the shipping company // For new vessels, we need the shipping company
if (!$dto->company?->id) {
if (!$dto->companyIri) {
throw new \Exception('ShippingCompany is required for new vessels'); throw new \Exception('ShippingCompany is required for new vessels');
} }


$company = $this->shippingCompanyRepository->find($dto->company->id);
$company = $this->shippingCompanyRepository->find($dto->companyIri->id);
if (!$company) { if (!$company) {
throw new \Exception('ShippingCompany not found'); throw new \Exception('ShippingCompany not found');
} }


Načítá se…
Zrušit
Uložit