From 7a07f10acfb5defb2e27401eb6943b93984b9a7c Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 16 Apr 2025 11:53:17 +0200 Subject: [PATCH] max depth 5 --- .../AuthenticationSuccessListener.php | 2 +- .../src/Mapper/LocationEntityToApiMapper.php | 2 +- httpdocs/src/Mapper/TripEntityToApiMapper.php | 6 +- .../Mapper/TripLocationEntityToApiMapper.php | 4 +- httpdocs/src/Mapper/UserEntityToApiMapper.php | 2 +- .../src/Mapper/UserTripEntityToApiMapper.php | 6 +- .../Mapper/UserTripEventApiToEntityMapper.php | 12 +-- .../Mapper/UserTripEventEntityToApiMapper.php | 8 +- .../UserTripLocationApiToEntityMapper.php | 70 ----------------- .../UserTripLocationEntityToApiMapper.php | 53 ------------- .../UserTripWorkLogApiToEntityMapper.php | 78 ------------------- .../UserTripWorkLogEntityToApiMapper.php | 58 -------------- .../src/Mapper/VesselEntityToApiMapper.php | 2 +- 13 files changed, 22 insertions(+), 281 deletions(-) delete mode 100644 httpdocs/src/Mapper/UserTripLocationApiToEntityMapper.php delete mode 100644 httpdocs/src/Mapper/UserTripLocationEntityToApiMapper.php delete mode 100644 httpdocs/src/Mapper/UserTripWorkLogApiToEntityMapper.php delete mode 100644 httpdocs/src/Mapper/UserTripWorkLogEntityToApiMapper.php diff --git a/httpdocs/src/EventListener/AuthenticationSuccessListener.php b/httpdocs/src/EventListener/AuthenticationSuccessListener.php index 2d5dc09..a1156e0 100644 --- a/httpdocs/src/EventListener/AuthenticationSuccessListener.php +++ b/httpdocs/src/EventListener/AuthenticationSuccessListener.php @@ -38,7 +38,7 @@ class AuthenticationSuccessListener } $userApi = $this->microMapper->map($user, UserApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $userIri = $this->iriConverter->getIriFromResource($userApi); diff --git a/httpdocs/src/Mapper/LocationEntityToApiMapper.php b/httpdocs/src/Mapper/LocationEntityToApiMapper.php index 91a634e..3dafd35 100644 --- a/httpdocs/src/Mapper/LocationEntityToApiMapper.php +++ b/httpdocs/src/Mapper/LocationEntityToApiMapper.php @@ -45,7 +45,7 @@ class LocationEntityToApiMapper implements MapperInterface $dto->createdAt = $entity->getCreatedAt(); $dto->zoneIri = $dto->zone = $this->microMapper->map($entity->getZone(), ZoneApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); return $dto; diff --git a/httpdocs/src/Mapper/TripEntityToApiMapper.php b/httpdocs/src/Mapper/TripEntityToApiMapper.php index 1025e30..66fdaae 100644 --- a/httpdocs/src/Mapper/TripEntityToApiMapper.php +++ b/httpdocs/src/Mapper/TripEntityToApiMapper.php @@ -47,15 +47,15 @@ class TripEntityToApiMapper implements MapperInterface // Map related entities $dto->vesselIri = $dto->vessel = $this->microMapper->map($entity->getVessel(), VesselApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->startLocationIri = $dto->startLocation = $this->microMapper->map($entity->getStartLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->endLocationIri = $dto->endLocation = $this->microMapper->map($entity->getEndLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); return $dto; diff --git a/httpdocs/src/Mapper/TripLocationEntityToApiMapper.php b/httpdocs/src/Mapper/TripLocationEntityToApiMapper.php index ef6110d..aa0dfe2 100644 --- a/httpdocs/src/Mapper/TripLocationEntityToApiMapper.php +++ b/httpdocs/src/Mapper/TripLocationEntityToApiMapper.php @@ -42,11 +42,11 @@ class TripLocationEntityToApiMapper implements MapperInterface $dto->createdAt = $entity->getCreatedAt(); $dto->trip = $this->microMapper->map($entity->getTrip(), TripApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->location = $this->microMapper->map($entity->getLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); return $dto; diff --git a/httpdocs/src/Mapper/UserEntityToApiMapper.php b/httpdocs/src/Mapper/UserEntityToApiMapper.php index 1c34e2e..ef993ed 100644 --- a/httpdocs/src/Mapper/UserEntityToApiMapper.php +++ b/httpdocs/src/Mapper/UserEntityToApiMapper.php @@ -50,7 +50,7 @@ class UserEntityToApiMapper implements MapperInterface $dto->imageIri = $dto->image = null; if ($entity->getImage() !== null) { $dto->imageIri = $dto->image = $this->microMapper->map($entity->getImage(), MediaObjectApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); } diff --git a/httpdocs/src/Mapper/UserTripEntityToApiMapper.php b/httpdocs/src/Mapper/UserTripEntityToApiMapper.php index 2599f98..5da3221 100644 --- a/httpdocs/src/Mapper/UserTripEntityToApiMapper.php +++ b/httpdocs/src/Mapper/UserTripEntityToApiMapper.php @@ -47,17 +47,17 @@ class UserTripEntityToApiMapper implements MapperInterface $dto->createdAt = $entity->getCreatedAt(); $dto->tripIri = $dto->trip = $this->microMapper->map($entity->getTrip(), TripApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->userIri = $dto->user = $this->microMapper->map($entity->getUser(), UserApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->signatureIri = $dto->signature = null; if ($entity->getSignature() !== null) { $dto->signatureIri = $dto->signature = $this->microMapper->map($entity->getSignature(), MediaObjectApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); } diff --git a/httpdocs/src/Mapper/UserTripEventApiToEntityMapper.php b/httpdocs/src/Mapper/UserTripEventApiToEntityMapper.php index f22c5d3..4b07e22 100644 --- a/httpdocs/src/Mapper/UserTripEventApiToEntityMapper.php +++ b/httpdocs/src/Mapper/UserTripEventApiToEntityMapper.php @@ -41,21 +41,21 @@ class UserTripEventApiToEntityMapper implements MapperInterface } $userTrip = $this->microMapper->map($dto->userTripIri, UserTrip::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); if (!$userTrip) { throw new \Exception('UserTrip not found'); } $event = $this->microMapper->map($dto->eventIri, Event::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); if (!$event) { throw new \Exception('Event not found'); } $location = $this->microMapper->map($dto->locationIri, Location::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); if (!$location) { throw new \Exception('Location not found'); @@ -72,7 +72,7 @@ class UserTripEventApiToEntityMapper implements MapperInterface assert($entity instanceof UserTripEvent); $userTrip = $this->microMapper->map($dto->userTripIri, UserTrip::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); if (!$userTrip) { throw new \Exception('UserTrip not found'); @@ -80,7 +80,7 @@ class UserTripEventApiToEntityMapper implements MapperInterface $entity->setUserTrip($userTrip); $event = $this->microMapper->map($dto->eventIri, Event::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); if (!$event) { throw new \Exception('Event not found'); @@ -88,7 +88,7 @@ class UserTripEventApiToEntityMapper implements MapperInterface $entity->setEvent($event); $location = $this->microMapper->map($dto->locationIri, Location::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); if (!$location) { throw new \Exception('Location not found'); diff --git a/httpdocs/src/Mapper/UserTripEventEntityToApiMapper.php b/httpdocs/src/Mapper/UserTripEventEntityToApiMapper.php index 03b2f34..cc7c0a4 100644 --- a/httpdocs/src/Mapper/UserTripEventEntityToApiMapper.php +++ b/httpdocs/src/Mapper/UserTripEventEntityToApiMapper.php @@ -44,19 +44,19 @@ class UserTripEventEntityToApiMapper implements MapperInterface $dto->createdAt = $entity->getCreatedAt(); $dto->userTripIri = $dto->userTrip = $this->microMapper->map($entity->getUserTrip(), UserTripApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->eventIri = $dto->event = $this->microMapper->map($entity->getEvent(), EventApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->locationIri = $dto->location = $this->microMapper->map($entity->getLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); $dto->user = $this->microMapper->map($entity->getUserTrip()->getUser(), UserApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); return $dto; diff --git a/httpdocs/src/Mapper/UserTripLocationApiToEntityMapper.php b/httpdocs/src/Mapper/UserTripLocationApiToEntityMapper.php deleted file mode 100644 index ed26739..0000000 --- a/httpdocs/src/Mapper/UserTripLocationApiToEntityMapper.php +++ /dev/null @@ -1,70 +0,0 @@ -id) { - $entity = $this->repository->find($dto->id); - if (!$entity) { - throw new \Exception('UserTripLocation not found'); - } - return $entity; - } - - // For new user trip locations, we need userTrip and location - if (!$dto->userTrip?->id || !$dto->location?->id) { - throw new \Exception('UserTrip and Location are required for new user trip locations'); - } - - $userTrip = $this->userTripRepository->find($dto->userTrip->id); - if (!$userTrip) { - throw new \Exception('UserTrip not found'); - } - - $location = $this->locationRepository->find($dto->location->id); - if (!$location) { - throw new \Exception('Location not found'); - } - - return new UserTripLocation( - $userTrip, - $location, - $dto->plannedDate - ); - } - - public function populate(object $from, object $to, array $context): object - { - $dto = $from; - $entity = $to; - assert($dto instanceof UserTripLocationApi); - assert($entity instanceof UserTripLocation); - - $entity->setPlannedDate($dto->plannedDate); - - return $entity; - } -} diff --git a/httpdocs/src/Mapper/UserTripLocationEntityToApiMapper.php b/httpdocs/src/Mapper/UserTripLocationEntityToApiMapper.php deleted file mode 100644 index 750afaa..0000000 --- a/httpdocs/src/Mapper/UserTripLocationEntityToApiMapper.php +++ /dev/null @@ -1,53 +0,0 @@ -id = $entity->getId(); - - return $dto; - } - - public function populate(object $from, object $to, array $context): object - { - $entity = $from; - $dto = $to; - assert($entity instanceof UserTripLocation); - assert($dto instanceof UserTripLocationApi); - - $dto->dbId = $entity->getId(); - $dto->plannedDate = $entity->getPlannedDate(); - $dto->createdAt = $entity->getCreatedAt(); - - $dto->userTrip = $this->microMapper->map($entity->getUserTrip(), UserTripApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, - ]); - - $dto->location = $this->microMapper->map($entity->getLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, - ]); - - return $dto; - } -} \ No newline at end of file diff --git a/httpdocs/src/Mapper/UserTripWorkLogApiToEntityMapper.php b/httpdocs/src/Mapper/UserTripWorkLogApiToEntityMapper.php deleted file mode 100644 index 2238cea..0000000 --- a/httpdocs/src/Mapper/UserTripWorkLogApiToEntityMapper.php +++ /dev/null @@ -1,78 +0,0 @@ -id) { - $entity = $this->repository->find($dto->id); - if (!$entity) { - throw new \Exception('UserTripWorkLog not found'); - } - return $entity; - } - - // For new work logs, we need userTrip and both locations - if (!$dto->userTrip?->id || !$dto->startLocation?->id || !$dto->endLocation?->id) { - throw new \Exception('UserTrip, start location and end location are required for new work logs'); - } - - $userTrip = $this->userTripRepository->find($dto->userTrip->id); - if (!$userTrip) { - throw new \Exception('UserTrip not found'); - } - - $startLocation = $this->locationRepository->find($dto->startLocation->id); - if (!$startLocation) { - throw new \Exception('Start location not found'); - } - - $endLocation = $this->locationRepository->find($dto->endLocation->id); - if (!$endLocation) { - throw new \Exception('End location not found'); - } - - return new UserTripWorkLog( - $userTrip, - $startLocation, - $endLocation, - $dto->startDate, - $dto->endDate - ); - } - - public function populate(object $from, object $to, array $context): object - { - $dto = $from; - $entity = $to; - assert($dto instanceof UserTripWorkLogApi); - assert($entity instanceof UserTripWorkLog); - - $entity->setStartDate($dto->startDate); - $entity->setEndDate($dto->endDate); - - return $entity; - } -} \ No newline at end of file diff --git a/httpdocs/src/Mapper/UserTripWorkLogEntityToApiMapper.php b/httpdocs/src/Mapper/UserTripWorkLogEntityToApiMapper.php deleted file mode 100644 index e98821f..0000000 --- a/httpdocs/src/Mapper/UserTripWorkLogEntityToApiMapper.php +++ /dev/null @@ -1,58 +0,0 @@ -id = $entity->getId(); - - return $dto; - } - - public function populate(object $from, object $to, array $context): object - { - $entity = $from; - $dto = $to; - assert($entity instanceof UserTripWorkLog); - assert($dto instanceof UserTripWorkLogApi); - - $dto->dbId = $entity->getId(); - $dto->startDate = $entity->getStartDate(); - $dto->endDate = $entity->getEndDate(); - $dto->createdAt = $entity->getCreatedAt(); - - $dto->userTrip = $this->microMapper->map($entity->getUserTrip(), UserTripApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, - ]); - - $dto->startLocation = $this->microMapper->map($entity->getStartLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, - ]); - - $dto->endLocation = $this->microMapper->map($entity->getEndLocation(), LocationApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, - ]); - - return $dto; - } -} \ No newline at end of file diff --git a/httpdocs/src/Mapper/VesselEntityToApiMapper.php b/httpdocs/src/Mapper/VesselEntityToApiMapper.php index 26be22c..8a85c8f 100644 --- a/httpdocs/src/Mapper/VesselEntityToApiMapper.php +++ b/httpdocs/src/Mapper/VesselEntityToApiMapper.php @@ -41,7 +41,7 @@ class VesselEntityToApiMapper implements MapperInterface $dto->createdAt = $entity->getCreatedAt(); $dto->company = $this->microMapper->map($entity->getCompany(), ShippingCompanyApi::class, [ - MicroMapperInterface::MAX_DEPTH => 3, + MicroMapperInterface::MAX_DEPTH => 5, ]); return $dto;