From 33a34485c60f856cd552cc225ffb6ed9e01a40dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P=2E?= Date: Mon, 15 Jun 2026 10:09:54 +0200 Subject: [PATCH] Adjust search for category --- src/Enum/FindingCategoryEnum.php | 10 +++++++--- src/Repository/FindingRepository.php | 2 +- src/Service/SearchService.php | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Enum/FindingCategoryEnum.php b/src/Enum/FindingCategoryEnum.php index d05fdfc..6b83fb4 100644 --- a/src/Enum/FindingCategoryEnum.php +++ b/src/Enum/FindingCategoryEnum.php @@ -6,7 +6,11 @@ namespace App\Enum; enum FindingCategoryEnum: string { - case s = 'scultura'; - case e = 'epigrafe'; - case p = 'pavimentazione'; + case a = 'arredo'; + case ab = 'abbigliamento e ornamenti personali'; + case d = 'decorazione parietale'; + case e = 'epigrafe'; + case el = 'elemento architettonico'; + case p = 'pavimentazione'; + case s = 'scultura'; } \ No newline at end of file diff --git a/src/Repository/FindingRepository.php b/src/Repository/FindingRepository.php index f1a01a2..07872d0 100644 --- a/src/Repository/FindingRepository.php +++ b/src/Repository/FindingRepository.php @@ -48,7 +48,7 @@ class FindingRepository extends ServiceEntityRepository if (!empty($filters['category'])) { $qb->andWhere('LOWER(s.category) = :category'); - $qb->setParameter('category', $filters['category']); + $qb->setParameter('category', strtolower($filters['category'])); } $qb->orderBy('s.label', 'ASC'); diff --git a/src/Service/SearchService.php b/src/Service/SearchService.php index d49317b..84fac45 100644 --- a/src/Service/SearchService.php +++ b/src/Service/SearchService.php @@ -32,7 +32,9 @@ final class SearchService if (empty($filters)) return new SearchResult([], [], [], [], 0); $sites = []; - if ((isset($filters['text']) && $filters['text'] !== '') || isset($filters['technique'])) { + if ((isset($filters['text']) && $filters['text'] !== '') || + (isset($filters['technique']) && $filters['technique'] !== '') + ) { $sites = array_map( fn(\App\Entity\Site $s) => $s->toSummary(), $this->siteRepository->findByFilters($filters) @@ -81,7 +83,7 @@ final class SearchService throw new InvalidFilterException("Invalid technique filter: " . $filters['technique']); } - if (!empty($filters['category']) && FindingCategoryEnum::tryFrom($filters['category']) === null) { + if (!empty($filters['category']) && FindingCategoryEnum::tryFrom(strtolower($filters['category'])) === null) { throw new InvalidFilterException("Invalid category filter: " . $filters['category']); }