Skip to content

Commit f453815

Browse files
committed
Import cards by order set
1 parent b4829ea commit f453815

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/AppBundle/Command/ImportStdCommand.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function configure()
3131
{
3232
$this
3333
->setName('app:import:std')
34-
->setDescription('Import cards data file in json format from a copy of https://github.com/Alsciende/thronesdb-json-data')
34+
->setDescription('Import cards data file in json format from a copy of https://github.com/fafranco82/swdestinydb-json-data')
3535
->addArgument(
3636
'path',
3737
InputArgument::REQUIRED,
@@ -159,8 +159,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
159159
// formats
160160

161161
$output->writeln("Importing Formats...");
162-
$setsFileInfo = $this->getFileInfo($path, 'formats.json');
163-
$imported = $this->importFormatsJsonFile($setsFileInfo);
162+
$formatFileInfo = $this->getFileInfo($path, 'formats.json');
163+
$imported = $this->importFormatsJsonFile($formatFileInfo);
164164
$question = new ConfirmationQuestion("Do you confirm? (Y/n) ", true);
165165
if(count($imported)) {
166166
$question = new ConfirmationQuestion("Do you confirm? (Y/n) ", true);
@@ -190,7 +190,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
190190

191191
// third, cards
192192

193-
$output->writeln("Importing Cards...");
193+
$this->tempCardMap = [];
194+
foreach ($this->em->getRepository('AppBundle:Set')->findAll() as $set) {
195+
$name = $set->getName();
196+
$code = $set->getCode();
197+
$output->writeln("Importing cards from set $name...");
198+
$fileinfo = $this->getFileInfo($path, "set/$code.json");
199+
$imported = $this->importCardsJsonFile($fileinfo);
200+
if(count($imported)) {
201+
$question = new ConfirmationQuestion("Do you confirm? (Y/n) ", true);
202+
if(!$helper->ask($input, $output, $question)) {
203+
die();
204+
}
205+
}
206+
$this->em->flush();
207+
}
208+
$this->loadCollection('Card');
209+
$output->writeln("Done.");
210+
211+
/*
194212
$fileSystemIterator = $this->getFileSystemIterator($path);
195213
$this->tempCardMap = [];
196214
foreach ($fileSystemIterator as $fileinfo) {
@@ -205,7 +223,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
205223
}
206224
$this->loadCollection('Card');
207225
$output->writeln("Done.");
208-
226+
*/
209227
$output->writeln("Importing Starter Packs...");
210228
$starterPacksFileInfo = $this->getFileInfo($path, 'starterPacks.json');
211229
$imported = $this->importStarterPacksJsonFile($starterPacksFileInfo);
@@ -216,6 +234,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
216234
die();
217235
}
218236
}
237+
219238
$this->em->flush();
220239
$output->writeln("Done.");
221240
}

0 commit comments

Comments
 (0)