diff --git a/composer.json b/composer.json
index 184e2d28a..748a7d862 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,6 @@
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.7",
"symfony/asset": "4.*",
- "symfony/http-client": "^4.4 || ^5",
"symfony/monolog-bundle": "^3.5",
"symfony/security-bundle": "4.*",
"symfony/translation": "4.*",
@@ -74,7 +73,7 @@
"symfony/web-profiler-bundle": "^5.0",
"symfony/var-dumper": "4.*",
"symfony/debug-bundle": "^5.1",
- "symfony/phpunit-bridge": "^5.2",
+ "symfony/phpunit-bridge": "^5.2",
"nelmio/alice": "^3.8"
},
"scripts": {
diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressReferenceCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressReferenceCommand.php
deleted file mode 100644
index e14851191..000000000
--- a/src/Bundle/ChillMainBundle/Command/LoadAddressReferenceCommand.php
+++ /dev/null
@@ -1,198 +0,0 @@
-entityManager = $entityManager;
- $this->client = $client;
- parent::__construct();
- }
-
- /*
- * (non-PHPdoc)
- * @see \Symfony\Component\Console\Command\Command::configure()
- */
- protected function configure(): void
- {
- $this
- ->setName('chill:main:address-reference:populate')
- ->setDescription('Load or update reference addresses in db. This command does not delete or update existing address reference,'.
- 'but will add new address reference entities based on their timestamp');
- }
-
- /*
- * (non-PHPdoc)
- * @see \Symfony\Component\Console\Command\Command::execute()
- */
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
-
- $maxCount = $this->countWFSFeatures($this->wfsBaseUrl, $output);
- $output->writeln('Number of addresses to be fetched: ' . $maxCount);
- $totalCount = 0;
- $batchSize = 100;
-
- $success = 0;
- $em = $this->entityManager;
-
- while($totalCount < $maxCount) {
-
- try {
- $addressReferenceArray = $this->fetchWFS($totalCount, $batchSize, $output);
- $success = $success + 1;
-
- foreach($addressReferenceArray as $a) {
- if (static::isAddressReferenceNew($a)) {
- $em->persist($a);
- }
- }
-
- $em->flush();
- $em->clear();
-
- } catch (\Exception $ex) {
- $output->writeln('Cannot fetch WFS. Error message is: '.$ex->getMessage().'');
- }
-
- $totalCount = $totalCount + $batchSize;
- }
-
- $em->flush();
-
- $output->writeln($success * $batchSize . '/'. $maxCount . 'reference address were loaded in the database.');
-
- return 0;
- }
-
- public static function isAddressReferenceNew(AddressReference $a): bool
- {
- $cond = true;
- // TODO: write this function
-
- return $cond;
- }
-
-
- private function countWFSFeatures(string $wfsBaseUrl, OutputInterface $output): int
- {
- $maxCountWfsUrl = $wfsBaseUrl . '&resultType=hits';
- try {
- $response = $this->client->request('GET', $maxCountWfsUrl);
- } catch (\Exception $ex) {
- $output->writeln('Cannot get WFS request working with '.$maxCountWfsUrl.' : '.$ex->getMessage().'');
- }
- if ($response->getStatusCode() === 200) {
- $content = $response->getContent();
- $count = explode('"', explode('numberMatched="', $content)[1])[0];
- } else {
- $output->writeln('Error getting WFS at ' . $maxCountWfsUrl . '. Status code is ' . $response->getStatusCode() . '.');
- }
-
- return $count;
- }
-
- /*
- * //TODO move this function in App and make the command generic by accepting a fetcher as an argument
- * @see \Symfony\Component\Console\Command\Command::execute()
- */
- private function fetchWFS(int $startIndex, int $count, OutputInterface $output): array
- {
-
- $countryCode = 'FR';
-
- $addressReferenceArray = array();
-
- $wfsBaseUrl = $this->wfsBaseUrl;
- $wfsUrl = $wfsBaseUrl . '&startIndex=' . $startIndex . '&count=' . $count . '&OUTPUTFORMAT=geojson';
- $output->writeln('Start fetching WFS data @: ' . $wfsUrl);
-
- try {
- $response = $this->client->request('GET', $wfsUrl);
- } catch (\Exception $ex) {
- $output->writeln('Cannot get WFS request working with '.$wfsUrl.' : '.$ex->getMessage().'');
- }
-
- if ($response->getStatusCode() === 200) {
-
- $content = $response->toArray();
-
- foreach ($content['features'] as $key => $value) {
-
- if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERY_VERBOSE) {
- $output->writeln('The address is ...');
- $output->write($value);
- }
-
- $a = new AddressReference();
-
- $x = $value['geometry']['coordinates'][0];
- $y = $value['geometry']['coordinates'][1];
-
- $lon = -1.4 + 0.01 * rand(-5, 5); //TODO temp: get the coordinates in EPSG:4326
- $lat = 46.5 + 0.01 * rand(-5, 5); //TODO temp: get the coordinates in EPSG:4326
-
- $point = Point::fromLonLat($lon, $lat);
-
- $em = $this->entityManager;
-
- $country = $em
- ->getRepository('ChillMainBundle:Country')
- ->findOneBy(array('countryCode' => $countryCode));
-
- $postcode = $em
- ->getRepository('ChillMainBundle:PostalCode')
- ->findOneBy(array('code' => $value['properties']['CODE_POST'], 'country' => $country));
-
- $a->setRefId($value['properties']['OBJECTID']);
- $a->setStreet($value['properties']['NOM_AFNOR']);
- $a->setStreetNumber($value['properties']['NUMERO']);
- $a->setPoint($point);
- $a->setPostcode($postcode);
- $a->setMunicipalityCode($value['properties']['CODE_INSEE']);
- $a->setSource($value['properties']['SOURCE']);
-
- $addressReferenceArray[] = $a;
- }
-
- } else {
- $output->writeln('Error getting WFS at ' . $wfsUrl . '. Status code is ' . $response->getStatusCode() . '.');
- }
-
- return $addressReferenceArray;
- }
-
-}
-
-
diff --git a/src/Bundle/ChillMainBundle/composer.json b/src/Bundle/ChillMainBundle/composer.json
index 0c95ec238..0c95c432a 100644
--- a/src/Bundle/ChillMainBundle/composer.json
+++ b/src/Bundle/ChillMainBundle/composer.json
@@ -26,8 +26,7 @@
],
"require": {
"league/csv": "^9.6",
- "phpoffice/phpspreadsheet": "~1.2",
- "symfony/http-client": "^4.4 || ^5"
+ "phpoffice/phpspreadsheet": "~1.2"
},
"require-dev": {
},
diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml
index eb07a16e2..20716e33b 100644
--- a/src/Bundle/ChillMainBundle/config/services.yaml
+++ b/src/Bundle/ChillMainBundle/config/services.yaml
@@ -66,9 +66,3 @@ services:
- "@chill.main.security.authorization.helper"
- "@security.token_storage"
- Chill\MainBundle\Command\:
- resource: '../Command/'
- autowire: true
- autoconfigure: true
- tags:
- - { name: console.command }