diff --git a/src/Command/SolrIndexing.php b/src/Command/SolrIndexing.php index 6a0837ad9c030d9e59a0f37c2ef9cf99a5d40800..74b7dbb7a822d5085b03a733626872c357db47bb 100644 --- a/src/Command/SolrIndexing.php +++ b/src/Command/SolrIndexing.php @@ -7,11 +7,13 @@ namespace App\Command; use App\Import\ImporterInterface; use App\Index\IndexerInterface; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class SolrIndexing extends Command { + protected static string $description = 'Process TEI data to solr data for importing into solr.'; protected static $defaultName = 'app:start_indexing'; private ImporterInterface $importer; private IndexerInterface $indexer; @@ -28,7 +30,9 @@ class SolrIndexing extends Command */ protected function configure() { - $this->setDescription('Process TEI data to solr data for importing into solr.'); + $this + ->setDescription(self::$description) + ->addArgument('server', InputArgument::REQUIRED, 'Server Type');; } /** @@ -36,12 +40,11 @@ class SolrIndexing extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { + $server = $input->getArgument('server'); $output->writeln('Start solr indexing.'); - - $this->importer->import(); + $this->importer->import($server); $this->indexer->deleteSolrIndex(); $this->indexer->tei2solr(); - $time = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']; $time /= 60; $output->writeln('Indexing process completed in '.$time.' minutes.'); diff --git a/src/Import/Importer.php b/src/Import/Importer.php index 15740b3408d3cfd00de442d0d4274e71113e24a0..cffd9d9db71b566af54dd2a610d9f29ef8730d68 100644 --- a/src/Import/Importer.php +++ b/src/Import/Importer.php @@ -85,9 +85,12 @@ class Importer implements ImporterInterface } } - public function import(): void + public function import(string $server): void { - $this->importSampleTeiDocument(); + if ('dev' === $server) { + $this->importSampleTeiDocument(); + } + $filesystem = new Filesystem(); if (!$filesystem->exists($this->teiDir)) { $filesystem->mkdir($this->teiDir); diff --git a/src/Import/ImporterInterface.php b/src/Import/ImporterInterface.php index 966fee6ffc427b3e22bd7cffeaef9dde95ca777a..26bcffab832afa16f62eaec5bd6f1ccb3eb4c839 100644 --- a/src/Import/ImporterInterface.php +++ b/src/Import/ImporterInterface.php @@ -4,5 +4,5 @@ namespace App\Import; interface ImporterInterface { - public function import(): void; + public function import(string $server): void; }