Skip to content

Commit

Permalink
fix: json file path
Browse files Browse the repository at this point in the history
  • Loading branch information
dr5hn committed Oct 5, 2024
1 parent 8d8d766 commit 30ef143
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bin/Commands/ExportCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ExportCsv extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{

$rootDir = PATH_BASE . '../..';
$rootDir = PATH_BASE . '../../json';

$files = array(
'countries' => array(
Expand Down Expand Up @@ -78,4 +78,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 1;
}

}
}
24 changes: 12 additions & 12 deletions bin/Commands/ExportJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$db = Config::getConfig()->getDB();

$rootDir = PATH_BASE . '../..';
$rootDir = PATH_BASE . '../../json';

$r = 0; // regions
$s = 0; // suberegions
Expand Down Expand Up @@ -277,7 +277,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Total Countries Count : '.count($countriesArray));
$output->writeln('Total States Count : '.count($statesArray));
$output->writeln('Total Cities Count : '.count($citiesArray));

$exportTo = $rootDir . '/countries.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countriesArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
Expand All @@ -290,55 +290,55 @@ protected function execute(InputInterface $input, OutputInterface $output)
fwrite($fp, json_encode($statesArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($citiesArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/states+cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($stateCityArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/countries+states.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countryStateArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/countries+cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countryCityArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/countries+states+cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countryStateCityArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/regions.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($regionsArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/subregions.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($subregionsArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);


$db->close();


return 1;
}


}
}
4 changes: 2 additions & 2 deletions bin/Commands/ExportXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ExportXml extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{

$rootDir = PATH_BASE . '../..';
$rootDir = PATH_BASE . '../../json';
$files = array(
'regions' => array(
'from' => '/regions.json',
Expand Down Expand Up @@ -92,4 +92,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
}


}
}
4 changes: 2 additions & 2 deletions bin/Commands/ExportYaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ExportYaml extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{

$rootDir = PATH_BASE . '../..';
$rootDir = PATH_BASE . '../../json';

$files = array(
'regions' => array(
Expand Down Expand Up @@ -82,4 +82,4 @@ protected function execute(InputInterface $input, OutputInterface $output)

return 1;
}
}
}
6 changes: 3 additions & 3 deletions docs/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ self.addEventListener('install', (e) => {
'./vendor/dynatable/css/jquery.dynatable.css',
'./vendor/dynatable/js/jquery.dynatable.js',
'./vendor/jquery/jquery.min.js',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/countries.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/states.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/cities.json'
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/countries.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/states.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/cities.json'
]);
})
);
Expand Down
2 changes: 1 addition & 1 deletion scripts/export_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Require Array2XML class which takes a PHP array and changes it to XML
require_once 'vendor/base.php';

$rootDir = dirname(dirname(__FILE__));
$rootDir = dirname(dirname(__FILE__)).'/json';
$files = array(
'countries' => array(
'from' => '/countries.json',
Expand Down
2 changes: 1 addition & 1 deletion scripts/export_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Spatie\ArrayToXml\ArrayToXml;

$rootDir = dirname(dirname(__FILE__));
$rootDir = dirname(dirname(__FILE__)).'/json';
$files = array(
'regions' => array(
'from' => '/regions.json',
Expand Down
2 changes: 1 addition & 1 deletion scripts/export_yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Symfony\Component\Yaml\Yaml;

$rootDir = dirname(dirname(__FILE__));
$rootDir = dirname(dirname(__FILE__)).'/json';
$files = array(
'regions' => array(
'from' => '/regions.json',
Expand Down

0 comments on commit 30ef143

Please sign in to comment.