From 2b88593e64c19cf522bf2cc7c47e7d0ec7ee24e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 8 Apr 2025 15:24:18 +0200 Subject: [PATCH] Add RegroupmentRepositoryInterface and integrate it Created a new `RegroupmentRepositoryInterface` to define repository methods for Regroupment entities. Updated `RegroupmentRepository` to implement this interface, and replaced its usage in `ExportConfigNormalizer` for better abstraction and testability. --- .../Export/ExportConfigNormalizer.php | 3 ++- .../Repository/RegroupmentRepository.php | 2 +- .../RegroupmentRepositoryInterface.php | 25 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Repository/RegroupmentRepositoryInterface.php diff --git a/src/Bundle/ChillMainBundle/Export/ExportConfigNormalizer.php b/src/Bundle/ChillMainBundle/Export/ExportConfigNormalizer.php index 8e5a2a990..46bd8b202 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportConfigNormalizer.php +++ b/src/Bundle/ChillMainBundle/Export/ExportConfigNormalizer.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Form\Type\Export\ExportType; use Chill\MainBundle\Form\Type\Export\FilterType; use Chill\MainBundle\Repository\CenterRepositoryInterface; use Chill\MainBundle\Repository\RegroupmentRepository; +use Chill\MainBundle\Repository\RegroupmentRepositoryInterface; /** * @phpstan-type NormalizedData array{centers: array{centers: list, regroupments: list}, export: array{form: array, version: int}, filters: array, version: int}>, aggregators: array, version: int}>, pick_formatter: string, formatter: array{form: array, version: int}} @@ -27,7 +28,7 @@ class ExportConfigNormalizer public function __construct( private readonly ExportManager $exportManager, private readonly CenterRepositoryInterface $centerRepository, - private readonly RegroupmentRepository $regroupmentRepository, + private readonly RegroupmentRepositoryInterface $regroupmentRepository, ) {} /** diff --git a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php index 793015f5b..76295cded 100644 --- a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php @@ -18,7 +18,7 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; use Doctrine\Persistence\ObjectRepository; -final readonly class RegroupmentRepository implements ObjectRepository +final readonly class RegroupmentRepository implements RegroupmentRepositoryInterface { private EntityRepository $repository; diff --git a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepositoryInterface.php b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepositoryInterface.php new file mode 100644 index 000000000..f3337df7a --- /dev/null +++ b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepositoryInterface.php @@ -0,0 +1,25 @@ + + */ +interface RegroupmentRepositoryInterface extends ObjectRepository +{ + /** + * @throws NonUniqueResultException + * @throws NoResultException + */ + public function findOneByName(string $name): ?Regroupment; + + /** + * @return array + */ + public function findRegroupmentAssociatedToNoCenter(): array; +}