Skip to content
Snippets Groups Projects
Commit 4741ef6d authored by Ján Forgáč's avatar Ján Forgáč
Browse files

CountryNameAlternatives: if current version file is missing, regenerate alternatives cache file

parent 20eedf85
No related branches found
Tags v2.1.1
No related merge requests found
Pipeline #36754 failed with stages
in 1 minute and 26 seconds
......@@ -50,11 +50,11 @@ class CountryNameAlternatives
} catch (\Exception $e) {
throw new MissingVersionFileException('version.txt file');
}
try {
$myVersion = new \DateTime(file_get_contents(self::PROJECT_VERSION));
} catch (\Exception $e) {
//silent
if (!file_exists(self::PROJECT_VERSION)) {
self::generateAlternativesCacheFile();
}
$myVersion = new \DateTime(file_get_contents(self::PROJECT_VERSION));
if (isset($myVersion) && $myVersion > $officialVersion) {
$countries = json_decode(file_get_contents(self::COUNTRY_NAMES_CACHE), true);
......@@ -65,6 +65,11 @@ class CountryNameAlternatives
}
}
self::generateAlternativesCacheFile();
}
private static function generateAlternativesCacheFile()
{
$handle = fopen(__DIR__ . '/countryNameAlternatives.csv', 'r');
while ($row = fgetcsv($handle, 1024, ',')) {
$countryCode = strtoupper($row[1]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment