fixup! Add ChillBundle normalization methods rector rule

This commit is contained in:
2025-03-12 21:51:24 +01:00
parent 0609e3f4c3
commit cac7d33a44
16 changed files with 119 additions and 26 deletions

View File

@@ -37,7 +37,7 @@ interface DirectExportInterface extends ExportElementInterface
public function denormalizeFormData(array $formData, int $fromVersion): array;
public function getVersion(): int;
public function getNormalizationVersion(): int;
/**
* get a description, which will be used in UI (and translated).

View File

@@ -155,6 +155,21 @@ class SpreadSheetFormatter implements FormatterInterface
}
}
public function getNormalizationVersion(): int
{
return 1;
}
public function normalizeFormData(array $formData): array
{
return $formData;
}
public function denormalizeFormData(array $formData, int $fromVersion): array
{
return $formData;
}
public function getFormDefaultData(array $aggregatorAliases): array
{
$data = ['format' => 'xlsx'];

View File

@@ -93,6 +93,21 @@ class SpreadsheetListFormatter implements FormatterInterface
]);
}
public function getNormalizationVersion(): int
{
return 1;
}
public function normalizeFormData(array $formData): array
{
return ['format' => $formData['format'], 'numerotation' => $formData['numerotation']];
}
public function denormalizeFormData(array $formData, int $fromVersion): array
{
return ['format' => $formData['format'], 'numerotation' => $formData['numerotation']];
}
public function getFormDefaultData(array $aggregatorAliases): array
{
return ['numerotation' => true, 'format' => 'xlsx'];

View File

@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\GeographicalUnit;
use Chill\MainBundle\Entity\GeographicalUnit\SimpleGeographicalUnitDTO;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
@@ -42,7 +43,7 @@ final readonly class GeographicalUnitRepository implements GeographicalUnitRepos
$qb = $this->buildQueryGeographicalUnitContainingAddress($address);
return $qb
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', SimpleGeographicalUnitDTO::class))
->addOrderBy('IDENTITY(gu.layer)')
->addOrderBy('gu.unitName')
->getQuery()
@@ -58,7 +59,7 @@ final readonly class GeographicalUnitRepository implements GeographicalUnitRepos
;
return $qb
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', SimpleGeographicalUnitDTO::class))
->innerJoin(Address::class, 'address', Join::WITH, 'ST_CONTAINS(gu.geom, address.point) = TRUE')
->where($qb->expr()->eq('address', ':address'))
->setParameter('address', $address)
@@ -70,6 +71,19 @@ final readonly class GeographicalUnitRepository implements GeographicalUnitRepos
return $this->repository->find($id);
}
public function findSimpleGeographicalUnit(int $id): ?SimpleGeographicalUnitDTO
{
$qb = $this->repository
->createQueryBuilder('gu');
return $qb
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', SimpleGeographicalUnitDTO::class))
->where('gu.id = :id')
->setParameter('id', $id)
->getQuery()
->getOneOrNullResult();
}
/**
* Will return only partial object, where the @see{GeographicalUnit::geom} property is not loaded.
*
@@ -79,7 +93,7 @@ final readonly class GeographicalUnitRepository implements GeographicalUnitRepos
{
return $this->repository
->createQueryBuilder('gu')
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', SimpleGeographicalUnitDTO::class))
->addOrderBy('IDENTITY(gu.layer)')
->addOrderBy('gu.unitName')
->getQuery()

View File

@@ -27,4 +27,6 @@ interface GeographicalUnitRepositoryInterface extends ObjectRepository
public function findGeographicalUnitContainingAddress(Address $address, int $offset = 0, int $limit = 50): array;
public function countGeographicalUnitContainingAddress(Address $address): int;
public function findSimpleGeographicalUnit(int $id): ?SimpleGeographicalUnitDTO;
}