From ac6b2d58321284e229a0cf20d3077955755e0832 Mon Sep 17 00:00:00 2001 From: Leonard Smith Date: Sat, 1 May 2021 16:42:58 -0500 Subject: [PATCH] Add output to the import handler to help with debugging --- app/Console/Commands/ImportUlbXmlData.php | 4 +++- app/Handlers/UlbXmlImportHandler.php | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/ImportUlbXmlData.php b/app/Console/Commands/ImportUlbXmlData.php index c998060..a0a1865 100644 --- a/app/Console/Commands/ImportUlbXmlData.php +++ b/app/Console/Commands/ImportUlbXmlData.php @@ -39,6 +39,7 @@ class ImportUlbXmlData extends Command */ public function handle() { + $this->info('Clearing out existing NT data...'); DB::statement("SET FOREIGN_KEY_CHECKS=0"); DB::table('verses')->truncate(); DB::table('chapters')->truncate(); @@ -46,7 +47,8 @@ class ImportUlbXmlData extends Command DB::table('words')->truncate(); DB::statement("SET FOREIGN_KEY_CHECKS=1"); - $importHandler = new UlbXmlImportHandler(); + $this->info('Importing fresh NT data...'); + $importHandler = new UlbXmlImportHandler($this->output); $importHandler->run(); } } diff --git a/app/Handlers/UlbXmlImportHandler.php b/app/Handlers/UlbXmlImportHandler.php index b10c529..9e6ede8 100644 --- a/app/Handlers/UlbXmlImportHandler.php +++ b/app/Handlers/UlbXmlImportHandler.php @@ -7,6 +7,10 @@ use App\Word; use App\Verse; use DOMDocument; use DOMElement; +use DOMNodeList; +use Illuminate\Console\OutputStyle; +use Symfony\Component\Console\Output\OutputInterface; + /** * UlbXmlImportHandler.php * @@ -45,6 +49,7 @@ class UlbXmlImportHandler foreach ($this->availableFiles as $name => $filepath) { $this->importBook($name, $filepath); } + $this->output->writeln("DONE.", OutputInterface::VERBOSITY_NORMAL); } /** @@ -54,8 +59,11 @@ class UlbXmlImportHandler */ public function importBook(string $bookTitle, string $filepath) : Book { - /** @var DOMDocument $document */ - $document = $this->openBook($filepath); + $this->currentBookNumber = $this->parseBookNumberFromFilepath($filepath); + + $this->output->write("Importing $bookTitle from $filepath Chapters: ", false, OutputInterface::VERBOSITY_NORMAL); + + $this->document = $this->openBook($filepath); $book = Book::create([ 'id' => strtolower($bookTitle), @@ -69,6 +77,8 @@ class UlbXmlImportHandler $book->chapters()->save($chapter); } + $this->output->write("Done.", true, OutputInterface::VERBOSITY_NORMAL); + return $book; }