1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-18 05:10:07 -07:00

Add RebrickableLoader

Loader to obtain Rebrickable database dump and load it to local database
This commit is contained in:
David Hübner 2017-03-10 23:37:23 +01:00
parent 1a9b856b3e
commit 0f7346068d
3 changed files with 13 additions and 16 deletions

View File

@ -18,8 +18,11 @@ services:
arguments: ['@doctrine.orm.entity_manager', '@manager.brickset','@manager.rebrickable']
loader.rebrickable:
class: AppBundle\Command\Loader\RebrickableLoader
arguments: ['@doctrine.orm.entity_manager', '@manager.rebrickable', '%rebrickable_url%' ]
class: AppBundle\Loader\RebrickableLoader
calls:
- [setArguments, ['@manager.rebrickable', '%rebrickable_url%']]
parent: service.loader
loader.ldraw:
class: AppBundle\Command\Loader\LDrawLoader
arguments: ['@doctrine.orm.entity_manager', '%kernel.root_dir%/../bin/ldview', '@oneup_flysystem.ldraw_filesystem', '%ldraw_url%']

View File

@ -3,32 +3,27 @@
namespace AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class LoadLibraryCommand extends ContainerAwareCommand
class LoadRebrickableDataCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('app:load:library')
->setDescription('Loads LDraw library parts')
->setHelp('This command allows you to..')
->addArgument('ldraw', InputArgument::OPTIONAL, 'Path to LDraw library folder');
->setName('app:load:rebrickable')
->setDescription('Loads Rebrickable database')
->setHelp('This command allows you to..');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$ldrawLoader = $this->getContainer()->get('loader.ldraw');
$ldrawLoader->setOutput($output);
$rebrickableLoader = $this->getContainer()->get('loader.rebrickable');
$rebrickableLoader->setOutput($output);
try {
$ldrawLoader->loadModels($input->getArgument('ldraw'));
//TODO log errors
try {
$rebrickableLoader->loadColors();
$rebrickableLoader->loadParts();

View File

@ -1,6 +1,6 @@
<?php
namespace AppBundle\Command\Loader;
namespace AppBundle\Loader;
use AppBundle\Api\Manager\RebrickableManager;
use AppBundle\Entity\BuildingKit;
@ -24,9 +24,8 @@ class RebrickableLoader extends Loader
/**
* ModelLoaderService constructor.
*/
public function __construct($em, $rebrickableManager, $rebrickable_url)
public function setArguments($rebrickableManager, $rebrickable_url)
{
$this->em = $em;
$this->rebrickableManager = $rebrickableManager;
$this->rebrickable_url = $rebrickable_url;
}