1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-31 19:20:13 -07:00

Fix service config

This commit is contained in:
David Hübner 2017-04-05 19:31:56 +02:00
parent 649121f1dc
commit 436624f751
7 changed files with 41 additions and 24 deletions

View File

@ -7,12 +7,15 @@ imports:
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration # http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters: parameters:
locale: en locale: en
# rebrickable csv files root URL
rebrickable_url: 'http://rebrickable.com/media/downloads/' rebrickable_url: 'http://rebrickable.com/media/downloads/'
ldraw_url: 'http://www.ldraw.org/library/updates/completeCA.zip' # LDraw library zip file URL
ldraw_url: 'http://www.ldraw.org/library/updates/complete.zip'
framework: framework:
#esi: ~ #esi: ~
#translator: { fallbacks: ["%locale%"] } translator:
fallbacks: ["%locale%"]
secret: "%secret%" secret: "%secret%"
router: router:
resource: "%kernel.root_dir%/config/routing.yml" resource: "%kernel.root_dir%/config/routing.yml"

View File

@ -1,14 +1,14 @@
services: services:
client.brickset: api.client.brickset:
class: AppBundle\Api\Client\Brickset\Brickset class: AppBundle\Api\Client\Brickset\Brickset
arguments: ['%brickset_apikey%'] arguments: ['%brickset_apikey%']
client.rebrickable: api.client.rebrickable:
class: AppBundle\Api\Client\Rebrickable\Rebrickable_v3 class: AppBundle\Api\Client\Rebrickable\Rebrickable_v3
arguments: ['%rebrickable_apikey%'] arguments: ['%rebrickable_apikey%']
manager.brickset: api.manager.brickset:
class: AppBundle\Api\Manager\BricksetManager class: AppBundle\Api\Manager\BricksetManager
arguments: ['@client.brickset'] arguments: ['@api.client.brickset']
manager.rebrickable: api.manager.rebrickable:
class: AppBundle\Api\Manager\RebrickableManager class: AppBundle\Api\Manager\RebrickableManager
arguments: ['@client.rebrickable'] arguments: ['@api.client.rebrickable']

View File

@ -11,9 +11,10 @@ services:
app.form.filter_set: app.form.filter_set:
class: AppBundle\Form\FilterSetType class: AppBundle\Form\FilterSetType
arguments: ['@manager.brickset'] arguments: ['@api.manager.brickset']
tags: tags:
- { name: form.type } app.relation.mapper: - { name: form.type }
app.relation.mapper: app.relation.mapper:
class: AppBundle\Utils\RelationMapper class: AppBundle\Utils\RelationMapper
arguments: arguments:

View File

@ -20,7 +20,7 @@ class LoadLDRawLibraryCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$ldrawLoader = $this->getContainer()->get('loader.ldraw'); $ldrawLoader = $this->getContainer()->get('service.loader.ldraw');
$ldrawLoader->setOutput($output); $ldrawLoader->setOutput($output);
//TODO log errors //TODO log errors

View File

@ -18,7 +18,7 @@ class LoadRebrickableDataCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$rebrickableLoader = $this->getContainer()->get('loader.rebrickable'); $rebrickableLoader = $this->getContainer()->get('service.loader.rebrickable');
$rebrickableLoader->setOutput($output); $rebrickableLoader->setOutput($output);
//TODO log errors //TODO log errors

View File

@ -43,7 +43,7 @@ class Color
/** /**
* @var Collection * @var Collection
* *
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Inventory_part", mappedBy="color") * @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Inventory_Part", mappedBy="color")
*/ */
protected $inventoryParts; protected $inventoryParts;

View File

@ -16,10 +16,15 @@ class LDViewService
private $ldview; private $ldview;
/** /**
* @var \League\Flysystem\Filesystem * @var Filesystem
*/ */
private $mediaFilesystem; private $mediaFilesystem;
/**
* @var Filesystem
*/
private $ldrawFilesystem;
/** /**
* LDViewService constructor. * LDViewService constructor.
* *
@ -32,6 +37,14 @@ class LDViewService
$this->mediaFilesystem = $mediaFilesystem; $this->mediaFilesystem = $mediaFilesystem;
} }
/**
* @param Filesystem $ldrawFilesystem
*/
public function setLdrawFilesystem($ldrawFilesystem)
{
$this->ldrawFilesystem = $ldrawFilesystem;
}
/** /**
* Convert LDraw model from .dat format to .stl by using LDView * Convert LDraw model from .dat format to .stl by using LDView
* stores created file to $stlStorage filesystem. * stores created file to $stlStorage filesystem.
@ -40,18 +53,18 @@ class LDViewService
* *
* @return File * @return File
*/ */
public function datToStl($file, $LDrawDir) public function datToStl($file, $LDrawDir = null)
{ {
if(!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'models')) { if (!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'models')) {
$this->mediaFilesystem->createDir('ldraw' . DIRECTORY_SEPARATOR . 'models'); $this->mediaFilesystem->createDir('ldraw'.DIRECTORY_SEPARATOR.'models');
} }
$newFile = 'ldraw'.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$file['filename'].'.stl'; $newFile = 'ldraw'.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$file['filename'].'.stl';
if (!$this->mediaFilesystem->has($newFile)) { if (!$this->mediaFilesystem->has($newFile)) {
$this->runLDView([ $this->runLDView([
$LDrawDir->getAdapter()->getPathPrefix().$file['path'], $this->ldrawFilesystem->getAdapter()->getPathPrefix().$file['path'],
'-LDrawDir='.$LDrawDir->getAdapter()->getPathPrefix(), '-LDrawDir='.$this->ldrawFilesystem->getAdapter()->getPathPrefix(),
'-ExportFiles=1', '-ExportFiles=1',
'-ExportSuffix=.stl', '-ExportSuffix=.stl',
'-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'ldraw'.DIRECTORY_SEPARATOR.'models', '-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'ldraw'.DIRECTORY_SEPARATOR.'models',
@ -74,18 +87,18 @@ class LDViewService
* *
* @return File * @return File
*/ */
public function datToPng($file, $LDrawDir) public function datToPng($file, $LDrawDir = null)
{ {
if(!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images')) { if (!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images')) {
$this->mediaFilesystem->createDir('ldraw' . DIRECTORY_SEPARATOR . 'images'); $this->mediaFilesystem->createDir('ldraw'.DIRECTORY_SEPARATOR.'images');
} }
$newFile = 'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$file['filename'].'.png'; $newFile = 'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$file['filename'].'.png';
if (!$this->mediaFilesystem->has($newFile)) { if (!$this->mediaFilesystem->has($newFile)) {
$this->runLDView([ $this->runLDView([
$LDrawDir->getAdapter()->getPathPrefix().$file['path'], $this->ldrawFilesystem->getAdapter()->getPathPrefix().$file['path'],
'-LDrawDir='.$LDrawDir->getAdapter()->getPathPrefix(), '-LDrawDir='.$this->ldrawFilesystem->getAdapter()->getPathPrefix(),
'-AutoCrop=1', '-AutoCrop=1',
'-SaveAlpha=0', '-SaveAlpha=0',
'-SnapshotSuffix=.png', '-SnapshotSuffix=.png',