Add output to the import handler to help with debugging
This commit is contained in:
parent
6e4cb11206
commit
ac6b2d5832
|
@ -39,6 +39,7 @@ class ImportUlbXmlData extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$this->info('Clearing out existing NT data...');
|
||||||
DB::statement("SET FOREIGN_KEY_CHECKS=0");
|
DB::statement("SET FOREIGN_KEY_CHECKS=0");
|
||||||
DB::table('verses')->truncate();
|
DB::table('verses')->truncate();
|
||||||
DB::table('chapters')->truncate();
|
DB::table('chapters')->truncate();
|
||||||
|
@ -46,7 +47,8 @@ class ImportUlbXmlData extends Command
|
||||||
DB::table('words')->truncate();
|
DB::table('words')->truncate();
|
||||||
DB::statement("SET FOREIGN_KEY_CHECKS=1");
|
DB::statement("SET FOREIGN_KEY_CHECKS=1");
|
||||||
|
|
||||||
$importHandler = new UlbXmlImportHandler();
|
$this->info('Importing fresh NT data...');
|
||||||
|
$importHandler = new UlbXmlImportHandler($this->output);
|
||||||
$importHandler->run();
|
$importHandler->run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ use App\Word;
|
||||||
use App\Verse;
|
use App\Verse;
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
|
use DOMNodeList;
|
||||||
|
use Illuminate\Console\OutputStyle;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UlbXmlImportHandler.php
|
* UlbXmlImportHandler.php
|
||||||
*
|
*
|
||||||
|
@ -45,6 +49,7 @@ class UlbXmlImportHandler
|
||||||
foreach ($this->availableFiles as $name => $filepath) {
|
foreach ($this->availableFiles as $name => $filepath) {
|
||||||
$this->importBook($name, $filepath);
|
$this->importBook($name, $filepath);
|
||||||
}
|
}
|
||||||
|
$this->output->writeln("<info>DONE.</info>", OutputInterface::VERBOSITY_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,8 +59,11 @@ class UlbXmlImportHandler
|
||||||
*/
|
*/
|
||||||
public function importBook(string $bookTitle, string $filepath) : Book
|
public function importBook(string $bookTitle, string $filepath) : Book
|
||||||
{
|
{
|
||||||
/** @var DOMDocument $document */
|
$this->currentBookNumber = $this->parseBookNumberFromFilepath($filepath);
|
||||||
$document = $this->openBook($filepath);
|
|
||||||
|
$this->output->write("<info>Importing $bookTitle from $filepath</info> Chapters: ", false, OutputInterface::VERBOSITY_NORMAL);
|
||||||
|
|
||||||
|
$this->document = $this->openBook($filepath);
|
||||||
|
|
||||||
$book = Book::create([
|
$book = Book::create([
|
||||||
'id' => strtolower($bookTitle),
|
'id' => strtolower($bookTitle),
|
||||||
|
@ -69,6 +77,8 @@ class UlbXmlImportHandler
|
||||||
$book->chapters()->save($chapter);
|
$book->chapters()->save($chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->output->write("<info>Done.</info>", true, OutputInterface::VERBOSITY_NORMAL);
|
||||||
|
|
||||||
return $book;
|
return $book;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue