diff --git a/src/AppBundle/Command/InitDataCommand.php b/src/AppBundle/Command/InitDataCommand.php index abe555d..042aa03 100644 --- a/src/AppBundle/Command/InitDataCommand.php +++ b/src/AppBundle/Command/InitDataCommand.php @@ -26,23 +26,26 @@ class InitDataCommand extends ContainerAwareCommand protected function execute(InputInterface $input, OutputInterface $output) { - $loadModelsCommand = $this->getApplication()->find('app:load:models'); + // Load LDraw data - $loadModelsInput = [ - 'command' => 'app:load:models', + $loadLDrawCommand = $this->getApplication()->find('app:load:ldraw'); + $loadLDrawInput = [ + 'command' => 'app:load:ldraw', '--all' => true, ]; if ($ldraw = $input->getOption('ldraw')) { - $loadModelsInput['--ldraw'] = $ldraw; + $loadLDrawInput['--ldraw'] = $ldraw; } - $returnCode = $loadModelsCommand->run(new ArrayInput($loadModelsInput), $output); + $returnCode = $loadLDrawCommand->run(new ArrayInput($loadLDrawInput), $output); if ($returnCode) { return 1; } + // Load Rebrickable data + $loadRebrickableCommad = $this->getApplication()->find('app:load:rebrickable'); $returnCode = $loadRebrickableCommad->run(new ArrayInput(['command' => 'app:load:rebrickable']), $output); @@ -50,14 +53,8 @@ class InitDataCommand extends ContainerAwareCommand return 1; } - $loadRelationsCommand = $this->getApplication()->find('app:load:relations'); - - $returnCode = $loadRelationsCommand->run(new ArrayInput(['command' => 'app:load:relations']), $output); - - if ($returnCode) { - return 1; - } - + // Load images + $loadImagesCommand = $this->getApplication()->find('app:load:images'); $returnCode = $loadImagesCommand->run(new ArrayInput([ 'command' => 'app:load:images', @@ -70,13 +67,6 @@ class InitDataCommand extends ContainerAwareCommand return 1; } - $elasticIndex = $this->getApplication()->find('fos:elastic:populate'); - $returnCode = $elasticIndex->run(null, $output); - - if ($returnCode) { - return 1; - } - return 0; } } diff --git a/src/AppBundle/Command/LoadModelImagesCommand.php b/src/AppBundle/Command/LoadImagesCommand.php similarity index 96% rename from src/AppBundle/Command/LoadModelImagesCommand.php rename to src/AppBundle/Command/LoadImagesCommand.php index 82b1126..797ea63 100644 --- a/src/AppBundle/Command/LoadModelImagesCommand.php +++ b/src/AppBundle/Command/LoadImagesCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class LoadModelImagesCommand extends ContainerAwareCommand +class LoadImagesCommand extends ContainerAwareCommand { protected function configure() { diff --git a/src/AppBundle/Command/LoadModelsCommand.php b/src/AppBundle/Command/LoadLdrawCommand.php similarity index 97% rename from src/AppBundle/Command/LoadModelsCommand.php rename to src/AppBundle/Command/LoadLdrawCommand.php index 3649ce4..e1e6bc3 100644 --- a/src/AppBundle/Command/LoadModelsCommand.php +++ b/src/AppBundle/Command/LoadLdrawCommand.php @@ -10,14 +10,14 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class LoadModelsCommand extends ContainerAwareCommand +class LoadLdrawCommand extends ContainerAwareCommand { use LockableTrait; protected function configure() { $this - ->setName('app:load:models') + ->setName('app:load:ldraw') ->setDescription('Loads LDraw library models into database') ->setHelp('This command allows you to load LDraw library models into database while converting .dat files to .stl format.') ->setDefinition( diff --git a/src/AppBundle/Command/LoadRebrickableDataCommand.php b/src/AppBundle/Command/LoadRebrickableDataCommand.php index ad760ca..986c98c 100644 --- a/src/AppBundle/Command/LoadRebrickableDataCommand.php +++ b/src/AppBundle/Command/LoadRebrickableDataCommand.php @@ -4,6 +4,7 @@ namespace AppBundle\Command; use League\Flysystem\Exception; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -29,5 +30,24 @@ class LoadRebrickableDataCommand extends ContainerAwareCommand return 1; } + + // Load relations between LDraw models and Rebrickable parts + $loadRelationsCommand = $this->getApplication()->find('app:load:relations'); + + $returnCode = $loadRelationsCommand->run(new ArrayInput(['command' => 'app:load:relations']), $output); + + if ($returnCode) { + return 1; + } + + // Populate Index + $elasticIndex = $this->getApplication()->find('fos:elastic:populate'); + $returnCode = $elasticIndex->run($input, $output); + + if ($returnCode) { + return 1; + } + + return 0; } }