Ver código fonte

max depth 5

master
Daniel 10 meses atrás
pai
commit
7a07f10acf
13 arquivos alterados com 22 adições e 281 exclusões
  1. +1
    -1
      httpdocs/src/EventListener/AuthenticationSuccessListener.php
  2. +1
    -1
      httpdocs/src/Mapper/LocationEntityToApiMapper.php
  3. +3
    -3
      httpdocs/src/Mapper/TripEntityToApiMapper.php
  4. +2
    -2
      httpdocs/src/Mapper/TripLocationEntityToApiMapper.php
  5. +1
    -1
      httpdocs/src/Mapper/UserEntityToApiMapper.php
  6. +3
    -3
      httpdocs/src/Mapper/UserTripEntityToApiMapper.php
  7. +6
    -6
      httpdocs/src/Mapper/UserTripEventApiToEntityMapper.php
  8. +4
    -4
      httpdocs/src/Mapper/UserTripEventEntityToApiMapper.php
  9. +0
    -70
      httpdocs/src/Mapper/UserTripLocationApiToEntityMapper.php
  10. +0
    -53
      httpdocs/src/Mapper/UserTripLocationEntityToApiMapper.php
  11. +0
    -78
      httpdocs/src/Mapper/UserTripWorkLogApiToEntityMapper.php
  12. +0
    -58
      httpdocs/src/Mapper/UserTripWorkLogEntityToApiMapper.php
  13. +1
    -1
      httpdocs/src/Mapper/VesselEntityToApiMapper.php

+ 1
- 1
httpdocs/src/EventListener/AuthenticationSuccessListener.php Ver arquivo

@@ -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);



+ 1
- 1
httpdocs/src/Mapper/LocationEntityToApiMapper.php Ver arquivo

@@ -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;


+ 3
- 3
httpdocs/src/Mapper/TripEntityToApiMapper.php Ver arquivo

@@ -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;


+ 2
- 2
httpdocs/src/Mapper/TripLocationEntityToApiMapper.php Ver arquivo

@@ -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;


+ 1
- 1
httpdocs/src/Mapper/UserEntityToApiMapper.php Ver arquivo

@@ -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,
]);
}



+ 3
- 3
httpdocs/src/Mapper/UserTripEntityToApiMapper.php Ver arquivo

@@ -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,
]);
}



+ 6
- 6
httpdocs/src/Mapper/UserTripEventApiToEntityMapper.php Ver arquivo

@@ -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');


+ 4
- 4
httpdocs/src/Mapper/UserTripEventEntityToApiMapper.php Ver arquivo

@@ -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;


+ 0
- 70
httpdocs/src/Mapper/UserTripLocationApiToEntityMapper.php Ver arquivo

@@ -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;
}
}

+ 0
- 53
httpdocs/src/Mapper/UserTripLocationEntityToApiMapper.php Ver arquivo

@@ -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;
}
}

+ 0
- 78
httpdocs/src/Mapper/UserTripWorkLogApiToEntityMapper.php Ver arquivo

@@ -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;
}
}

+ 0
- 58
httpdocs/src/Mapper/UserTripWorkLogEntityToApiMapper.php Ver arquivo

@@ -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;
}
}

+ 1
- 1
httpdocs/src/Mapper/VesselEntityToApiMapper.php Ver arquivo

@@ -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;


Carregando…
Cancelar
Salvar