|
|
|
@@ -19,6 +19,8 @@ class UserTripApiToEntityMapper implements MapperInterface |
|
|
|
{ |
|
|
|
public function __construct( |
|
|
|
private UserTripRepository $repository, |
|
|
|
private TripRepository $tripRepository, |
|
|
|
private UserRepository $userRepository, |
|
|
|
private MediaObjectRepository $mediaObjectRepository, |
|
|
|
private MicroMapperInterface $microMapper |
|
|
|
) { |
|
|
|
@@ -42,16 +44,12 @@ class UserTripApiToEntityMapper implements MapperInterface |
|
|
|
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) { |
|
|
|
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) { |
|
|
|
throw new \Exception('User not found'); |
|
|
|
} |
|
|
|
|