| @@ -38,7 +38,7 @@ class AuthenticationSuccessListener | |||||
| } | } | ||||
| $userApi = $this->microMapper->map($user, UserApi::class, [ | $userApi = $this->microMapper->map($user, UserApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| $userIri = $this->iriConverter->getIriFromResource($userApi); | $userIri = $this->iriConverter->getIriFromResource($userApi); | ||||
| @@ -45,7 +45,7 @@ class LocationEntityToApiMapper implements MapperInterface | |||||
| $dto->createdAt = $entity->getCreatedAt(); | $dto->createdAt = $entity->getCreatedAt(); | ||||
| $dto->zoneIri = $dto->zone = $this->microMapper->map($entity->getZone(), ZoneApi::class, [ | $dto->zoneIri = $dto->zone = $this->microMapper->map($entity->getZone(), ZoneApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| return $dto; | return $dto; | ||||
| @@ -47,15 +47,15 @@ class TripEntityToApiMapper implements MapperInterface | |||||
| // Map related entities | // Map related entities | ||||
| $dto->vesselIri = $dto->vessel = $this->microMapper->map($entity->getVessel(), VesselApi::class, [ | $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, [ | $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, [ | $dto->endLocationIri = $dto->endLocation = $this->microMapper->map($entity->getEndLocation(), LocationApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| return $dto; | return $dto; | ||||
| @@ -42,11 +42,11 @@ class TripLocationEntityToApiMapper implements MapperInterface | |||||
| $dto->createdAt = $entity->getCreatedAt(); | $dto->createdAt = $entity->getCreatedAt(); | ||||
| $dto->trip = $this->microMapper->map($entity->getTrip(), TripApi::class, [ | $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, [ | $dto->location = $this->microMapper->map($entity->getLocation(), LocationApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| return $dto; | return $dto; | ||||
| @@ -50,7 +50,7 @@ class UserEntityToApiMapper implements MapperInterface | |||||
| $dto->imageIri = $dto->image = null; | $dto->imageIri = $dto->image = null; | ||||
| if ($entity->getImage() !== null) { | if ($entity->getImage() !== null) { | ||||
| $dto->imageIri = $dto->image = $this->microMapper->map($entity->getImage(), MediaObjectApi::class, [ | $dto->imageIri = $dto->image = $this->microMapper->map($entity->getImage(), MediaObjectApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| } | } | ||||
| @@ -47,17 +47,17 @@ class UserTripEntityToApiMapper implements MapperInterface | |||||
| $dto->createdAt = $entity->getCreatedAt(); | $dto->createdAt = $entity->getCreatedAt(); | ||||
| $dto->tripIri = $dto->trip = $this->microMapper->map($entity->getTrip(), TripApi::class, [ | $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, [ | $dto->userIri = $dto->user = $this->microMapper->map($entity->getUser(), UserApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| $dto->signatureIri = $dto->signature = null; | $dto->signatureIri = $dto->signature = null; | ||||
| if ($entity->getSignature() !== null) { | if ($entity->getSignature() !== null) { | ||||
| $dto->signatureIri = $dto->signature = $this->microMapper->map($entity->getSignature(), MediaObjectApi::class, [ | $dto->signatureIri = $dto->signature = $this->microMapper->map($entity->getSignature(), MediaObjectApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| } | } | ||||
| @@ -41,21 +41,21 @@ class UserTripEventApiToEntityMapper implements MapperInterface | |||||
| } | } | ||||
| $userTrip = $this->microMapper->map($dto->userTripIri, UserTrip::class, [ | $userTrip = $this->microMapper->map($dto->userTripIri, UserTrip::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| if (!$userTrip) { | if (!$userTrip) { | ||||
| throw new \Exception('UserTrip not found'); | throw new \Exception('UserTrip not found'); | ||||
| } | } | ||||
| $event = $this->microMapper->map($dto->eventIri, Event::class, [ | $event = $this->microMapper->map($dto->eventIri, Event::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| if (!$event) { | if (!$event) { | ||||
| throw new \Exception('Event not found'); | throw new \Exception('Event not found'); | ||||
| } | } | ||||
| $location = $this->microMapper->map($dto->locationIri, Location::class, [ | $location = $this->microMapper->map($dto->locationIri, Location::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| if (!$location) { | if (!$location) { | ||||
| throw new \Exception('Location not found'); | throw new \Exception('Location not found'); | ||||
| @@ -72,7 +72,7 @@ class UserTripEventApiToEntityMapper implements MapperInterface | |||||
| assert($entity instanceof UserTripEvent); | assert($entity instanceof UserTripEvent); | ||||
| $userTrip = $this->microMapper->map($dto->userTripIri, UserTrip::class, [ | $userTrip = $this->microMapper->map($dto->userTripIri, UserTrip::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| if (!$userTrip) { | if (!$userTrip) { | ||||
| throw new \Exception('UserTrip not found'); | throw new \Exception('UserTrip not found'); | ||||
| @@ -80,7 +80,7 @@ class UserTripEventApiToEntityMapper implements MapperInterface | |||||
| $entity->setUserTrip($userTrip); | $entity->setUserTrip($userTrip); | ||||
| $event = $this->microMapper->map($dto->eventIri, Event::class, [ | $event = $this->microMapper->map($dto->eventIri, Event::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| if (!$event) { | if (!$event) { | ||||
| throw new \Exception('Event not found'); | throw new \Exception('Event not found'); | ||||
| @@ -88,7 +88,7 @@ class UserTripEventApiToEntityMapper implements MapperInterface | |||||
| $entity->setEvent($event); | $entity->setEvent($event); | ||||
| $location = $this->microMapper->map($dto->locationIri, Location::class, [ | $location = $this->microMapper->map($dto->locationIri, Location::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| if (!$location) { | if (!$location) { | ||||
| throw new \Exception('Location not found'); | throw new \Exception('Location not found'); | ||||
| @@ -44,19 +44,19 @@ class UserTripEventEntityToApiMapper implements MapperInterface | |||||
| $dto->createdAt = $entity->getCreatedAt(); | $dto->createdAt = $entity->getCreatedAt(); | ||||
| $dto->userTripIri = $dto->userTrip = $this->microMapper->map($entity->getUserTrip(), UserTripApi::class, [ | $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, [ | $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, [ | $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, [ | $dto->user = $this->microMapper->map($entity->getUserTrip()->getUser(), UserApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| return $dto; | return $dto; | ||||
| @@ -1,70 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Mapper; | |||||
| use App\ApiResource\UserTripLocationApi; | |||||
| use App\Entity\UserTripLocation; | |||||
| use App\Repository\UserTripLocationRepository; | |||||
| use App\Repository\UserTripRepository; | |||||
| use App\Repository\LocationRepository; | |||||
| use Symfonycasts\MicroMapper\AsMapper; | |||||
| use Symfonycasts\MicroMapper\MapperInterface; | |||||
| use Symfonycasts\MicroMapper\MicroMapperInterface; | |||||
| #[AsMapper(from: UserTripLocationApi::class, to: UserTripLocation::class)] | |||||
| class UserTripLocationApiToEntityMapper implements MapperInterface | |||||
| { | |||||
| public function __construct( | |||||
| private UserTripLocationRepository $repository, | |||||
| private UserTripRepository $userTripRepository, | |||||
| private LocationRepository $locationRepository, | |||||
| ) { | |||||
| } | |||||
| public function load(object $from, string $toClass, array $context): object | |||||
| { | |||||
| $dto = $from; | |||||
| assert($dto instanceof UserTripLocationApi); | |||||
| if ($dto->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; | |||||
| } | |||||
| } | |||||
| @@ -1,53 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Mapper; | |||||
| use App\ApiResource\LocationApi; | |||||
| use App\ApiResource\UserTripApi; | |||||
| use App\ApiResource\UserTripLocationApi; | |||||
| use App\Entity\UserTripLocation; | |||||
| use Symfonycasts\MicroMapper\AsMapper; | |||||
| use Symfonycasts\MicroMapper\MapperInterface; | |||||
| use Symfonycasts\MicroMapper\MicroMapperInterface; | |||||
| #[AsMapper(from: UserTripLocation::class, to: UserTripLocationApi::class)] | |||||
| class UserTripLocationEntityToApiMapper implements MapperInterface | |||||
| { | |||||
| public function __construct( | |||||
| private MicroMapperInterface $microMapper | |||||
| ) { | |||||
| } | |||||
| public function load(object $from, string $toClass, array $context): object | |||||
| { | |||||
| $entity = $from; | |||||
| assert($entity instanceof UserTripLocation); | |||||
| $dto = new UserTripLocationApi(); | |||||
| $dto->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; | |||||
| } | |||||
| } | |||||
| @@ -1,78 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Mapper; | |||||
| use App\ApiResource\UserTripWorkLogApi; | |||||
| use App\Entity\UserTripWorkLog; | |||||
| use App\Repository\UserTripWorkLogRepository; | |||||
| use App\Repository\UserTripRepository; | |||||
| use App\Repository\LocationRepository; | |||||
| use Symfonycasts\MicroMapper\AsMapper; | |||||
| use Symfonycasts\MicroMapper\MapperInterface; | |||||
| use Symfonycasts\MicroMapper\MicroMapperInterface; | |||||
| #[AsMapper(from: UserTripWorkLogApi::class, to: UserTripWorkLog::class)] | |||||
| class UserTripWorkLogApiToEntityMapper implements MapperInterface | |||||
| { | |||||
| public function __construct( | |||||
| private UserTripWorkLogRepository $repository, | |||||
| private UserTripRepository $userTripRepository, | |||||
| private LocationRepository $locationRepository, | |||||
| ) { | |||||
| } | |||||
| public function load(object $from, string $toClass, array $context): object | |||||
| { | |||||
| $dto = $from; | |||||
| assert($dto instanceof UserTripWorkLogApi); | |||||
| if ($dto->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; | |||||
| } | |||||
| } | |||||
| @@ -1,58 +0,0 @@ | |||||
| <?php | |||||
| namespace App\Mapper; | |||||
| use App\ApiResource\LocationApi; | |||||
| use App\ApiResource\UserTripApi; | |||||
| use App\ApiResource\UserTripWorkLogApi; | |||||
| use App\Entity\UserTripWorkLog; | |||||
| use Symfonycasts\MicroMapper\AsMapper; | |||||
| use Symfonycasts\MicroMapper\MapperInterface; | |||||
| use Symfonycasts\MicroMapper\MicroMapperInterface; | |||||
| #[AsMapper(from: UserTripWorkLog::class, to: UserTripWorkLogApi::class)] | |||||
| class UserTripWorkLogEntityToApiMapper implements MapperInterface | |||||
| { | |||||
| public function __construct( | |||||
| private MicroMapperInterface $microMapper | |||||
| ) { | |||||
| } | |||||
| public function load(object $from, string $toClass, array $context): object | |||||
| { | |||||
| $entity = $from; | |||||
| assert($entity instanceof UserTripWorkLog); | |||||
| $dto = new UserTripWorkLogApi(); | |||||
| $dto->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; | |||||
| } | |||||
| } | |||||
| @@ -41,7 +41,7 @@ class VesselEntityToApiMapper implements MapperInterface | |||||
| $dto->createdAt = $entity->getCreatedAt(); | $dto->createdAt = $entity->getCreatedAt(); | ||||
| $dto->company = $this->microMapper->map($entity->getCompany(), ShippingCompanyApi::class, [ | $dto->company = $this->microMapper->map($entity->getCompany(), ShippingCompanyApi::class, [ | ||||
| MicroMapperInterface::MAX_DEPTH => 3, | |||||
| MicroMapperInterface::MAX_DEPTH => 5, | |||||
| ]); | ]); | ||||
| return $dto; | return $dto; | ||||