mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-17 21:00:09 -07:00
Add load not paired realations option
This commit is contained in:
parent
738e2698ba
commit
bc9efea8c3
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace AppBundle\Command;
|
namespace AppBundle\Command;
|
||||||
|
|
||||||
|
use AppBundle\Service\Loader\RelationLoader;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputDefinition;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class LoadRelationCommand extends ContainerAwareCommand
|
class LoadRelationCommand extends ContainerAwareCommand
|
||||||
@ -13,11 +16,17 @@ class LoadRelationCommand extends ContainerAwareCommand
|
|||||||
$this
|
$this
|
||||||
->setName('app:load:relations')
|
->setName('app:load:relations')
|
||||||
->setDescription('Loads relations between LDraw models and Rebrickable parts.')
|
->setDescription('Loads relations between LDraw models and Rebrickable parts.')
|
||||||
->setHelp('This command allows you to load relation between models and parts into database.');
|
->setHelp('This command allows you to load relation between models and parts into database.')
|
||||||
|
->setDefinition(
|
||||||
|
new InputDefinition([
|
||||||
|
new InputOption('rewrite', 'r', InputOption::VALUE_NONE, 'Reload relations for all Rebrickable parts.'),
|
||||||
|
])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
/** @var RelationLoader $relationLoader */
|
||||||
$relationLoader = $this->getContainer()->get('service.loader.relation');
|
$relationLoader = $this->getContainer()->get('service.loader.relation');
|
||||||
$relationLoader->setOutput($output);
|
$relationLoader->setOutput($output);
|
||||||
|
|
||||||
@ -27,7 +36,11 @@ class LoadRelationCommand extends ContainerAwareCommand
|
|||||||
'<fg=cyan>------------------------------------------------------------------------------</>',
|
'<fg=cyan>------------------------------------------------------------------------------</>',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$relationLoader->loadAll();
|
if ($input->getOption('rewrite')) {
|
||||||
|
$relationLoader->loadAll();
|
||||||
|
} else {
|
||||||
|
$relationLoader->loadNotPaired();
|
||||||
|
}
|
||||||
|
|
||||||
$output->writeln(['<info>Done!</info>']);
|
$output->writeln(['<info>Done!</info>']);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class RelationLoader extends BaseLoader
|
|||||||
$this->load($parts);
|
$this->load($parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadNotPaired($parts)
|
public function loadNotPaired()
|
||||||
{
|
{
|
||||||
$parts = $this->partRepository->findAllNotPaired();
|
$parts = $this->partRepository->findAllNotPaired();
|
||||||
$this->load($parts);
|
$this->load($parts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user