From 03b24968173a65cb7957448dc9fdaf00380ce526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Mar 2025 23:02:19 +0100 Subject: [PATCH 1/3] Fix dependency injection issues in AbstractCRUDController Replaced incorrect service definitions in AbstractCRUDController to ensure proper dependency injection. Specifically, fixed retrieval of the ManagerRegistry and Validator services to resolve CalendarRange save errors (Issue #362). No schema changes were introduced. --- .changes/unreleased/Fixed-20250304-160058.yaml | 6 ++++++ .../CRUD/Controller/AbstractCRUDController.php | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixed-20250304-160058.yaml diff --git a/.changes/unreleased/Fixed-20250304-160058.yaml b/.changes/unreleased/Fixed-20250304-160058.yaml new file mode 100644 index 000000000..d2e9cf3ed --- /dev/null +++ b/.changes/unreleased/Fixed-20250304-160058.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix Dependency Injection, which prevented to save the CalendarRange +time: 2025-03-04T16:00:58.269626007+01:00 +custom: + Issue: "362" + SchemaChange: No schema change diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php index ea5e55a69..1cbf69630 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php @@ -63,7 +63,6 @@ abstract class AbstractCRUDController extends AbstractController parent::getSubscribedServices(), [ 'chill_main.paginator_factory' => PaginatorFactory::class, - ManagerRegistry::class => ManagerRegistry::class, 'translator' => TranslatorInterface::class, AuthorizationHelper::class => AuthorizationHelper::class, EventDispatcherInterface::class => EventDispatcherInterface::class, @@ -213,7 +212,7 @@ abstract class AbstractCRUDController extends AbstractController protected function getManagerRegistry(): ManagerRegistry { - return $this->container->get(ManagerRegistry::class); + return $this->container->get('doctrine'); } /** @@ -226,7 +225,7 @@ abstract class AbstractCRUDController extends AbstractController protected function getValidator(): ValidatorInterface { - return $this->get('validator'); + return $this->container->get('validator'); } /** From 08af5307269984d6a0ef63c0f7094a53a5213e9e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Mar 2025 10:26:22 +0100 Subject: [PATCH 2/3] Replace deprecated Statement::create() method use constructor directly --- .../AddressReferenceBEFromBestAddress.php | 4 ++-- .../Import/AddressReferenceFromBAN.php | 4 ++-- .../Import/AddressReferenceFromBano.php | 22 +++++++++---------- .../Service/Import/AddressReferenceLU.php | 6 +++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index ea6575e43..fcf49079f 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -68,8 +68,8 @@ class AddressReferenceBEFromBestAddress $csv->setDelimiter(','); $csv->setHeaderOffset(0); - $stmt = Statement::create() - ->process($csv); + $stmt = new Statement(); + $stmt = $stmt->process($csv); foreach ($stmt as $record) { $this->baseImporter->importAddress( diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php index b45760592..d79997b0a 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php @@ -55,8 +55,8 @@ class AddressReferenceFromBAN $csv = Reader::createFromStream($csvDecompressed); $csv->setDelimiter(';')->setHeaderOffset(0); - $stmt = Statement::create() - ->process($csv, [ + $stmt = new Statement(); + $stmt = $stmt->process($csv, [ 'id', 'id_fantoir', 'numero', diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php index 5ee3f6964..be20bbc11 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php @@ -43,17 +43,17 @@ class AddressReferenceFromBano $csv = Reader::createFromStream($file); $csv->setDelimiter(','); - $stmt = Statement::create() - ->process($csv, [ - 'refId', - 'streetNumber', - 'street', - 'postcode', - 'city', - '_o', - 'lat', - 'lon', - ]); + $stmt = new Statement(); + $stmt = $stmt->process($csv, [ + 'refId', + 'streetNumber', + 'street', + 'postcode', + 'city', + '_o', + 'lat', + 'lon', + ]); foreach ($stmt as $record) { $this->baseImporter->importAddress( diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php index 86c1b61b8..e1294732b 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php @@ -54,7 +54,8 @@ class AddressReferenceLU private function process_address(Reader $csv, ?string $sendAddressReportToEmail = null): void { - $stmt = Statement::create()->process($csv); + $stmt = new Statement(); + $stmt = $stmt->process($csv); foreach ($stmt as $record) { $this->addressBaseImporter->importAddress( $record['id_geoportail'], @@ -74,7 +75,8 @@ class AddressReferenceLU private function process_postal_code(Reader $csv): void { - $stmt = Statement::create()->process($csv); + $stmt = new Statement(); + $stmt = $stmt->process($csv); $arr_postal_codes = []; foreach ($stmt as $record) { if (false === \array_key_exists($record['code_postal'], $arr_postal_codes)) { From 84b7cc81452a670d89172af32a9b733d19fd1056 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Mar 2025 10:46:36 +0100 Subject: [PATCH 3/3] Php cs fixes --- .../Import/AddressReferenceFromBAN.php | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php index d79997b0a..1c03b7bfb 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBAN.php @@ -57,30 +57,30 @@ class AddressReferenceFromBAN $csv->setDelimiter(';')->setHeaderOffset(0); $stmt = new Statement(); $stmt = $stmt->process($csv, [ - 'id', - 'id_fantoir', - 'numero', - 'rep', - 'nom_voie', - 'code_postal', - 'code_insee', - 'nom_commune', - 'code_insee_ancienne_commune', - 'nom_ancienne_commune', - 'x', - 'y', - 'lon', - 'lat', - 'type_position', - 'alias', - 'nom_ld', - 'libelle_acheminement', - 'nom_afnor', - 'source_position', - 'source_nom_voie', - 'certification_commune', - 'cad_parcelles', - ]); + 'id', + 'id_fantoir', + 'numero', + 'rep', + 'nom_voie', + 'code_postal', + 'code_insee', + 'nom_commune', + 'code_insee_ancienne_commune', + 'nom_ancienne_commune', + 'x', + 'y', + 'lon', + 'lat', + 'type_position', + 'alias', + 'nom_ld', + 'libelle_acheminement', + 'nom_afnor', + 'source_position', + 'source_nom_voie', + 'certification_commune', + 'cad_parcelles', + ]); foreach ($stmt as $record) { $this->baseImporter->importAddress(