Fix loading countries

This commit is contained in:
2023-07-30 22:01:55 +02:00
parent 770d64a2f8
commit 984c35f8bc
3 changed files with 26 additions and 36 deletions

View File

@@ -16,6 +16,7 @@ use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Intl\Countries;
use Symfony\Component\Intl\Intl;
class LoadCountriesCommand extends Command
@@ -32,24 +33,18 @@ class LoadCountriesCommand extends Command
public static function prepareCountryList($languages)
{
$regionBundle = Intl::getRegionBundle();
$countries = [];
foreach ($languages as $language) {
$countries[$language] = \Symfony\Component\Intl\Currencies::getNames();
}
$countryCodes = Countries::getCountryCodes();
$countryEntities = [];
foreach ($countries[$languages[0]] as $countryCode => $name) {
foreach ($countryCodes as $code) {
$names = [];
foreach ($languages as $language) {
$names[$language] = $countries[$language][$countryCode];
$names[$language] = Countries::getName($code, $language);
}
$country = new \Chill\MainBundle\Entity\Country();
$country->setName($names)->setCountryCode($countryCode);
$country->setName($names)->setCountryCode($code);
$countryEntities[] = $country;
}