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

Fix color dependencies

This commit is contained in:
David Hübner 2017-04-24 11:07:44 +02:00
parent 328d14426e
commit 7e31eee729
5 changed files with 40 additions and 21 deletions

View File

@ -1,5 +1,9 @@
{% extends 'base.html.twig' %}
{% block title %}{{ 'page.color' | trans }}{% endblock %}
{% block header %}{{ 'page.color' | trans }}{% endblock %}
{% block content %}
<table class="ui celled small padded table">

View File

@ -1,4 +1,10 @@
services:
repository.color:
class: Doctrine\ORM\EntityRepository
factory: ["@doctrine", getRepository]
arguments:
- AppBundle\Entity\Color
repository.ldraw.keyword:
class: Doctrine\ORM\EntityRepository
factory: ["@doctrine", getRepository]
@ -54,12 +60,6 @@ services:
arguments:
- AppBundle\Entity\Rebrickable\Category
repository.rebrickable.color:
class: Doctrine\ORM\EntityRepository
factory: ["@doctrine", getRepository]
arguments:
- AppBundle\Entity\Rebrickable\Color
repository.rebrickable.inventory:
class: Doctrine\ORM\EntityRepository
factory: ["@doctrine", getRepository]

View File

@ -42,7 +42,7 @@ class LoadModelImagesCommand extends ContainerAwareCommand
}
if($input->getOption('models')) {
$imageLoaderService->loadMissingModelImages($color);
$imageLoaderService->loadMissingModelImages();
}
}
}

View File

@ -1,15 +1,14 @@
<?php
namespace AppBundle\Controller\Rebrickable;
namespace AppBundle\Controller;
use AppBundle\Entity\Color;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* Part controller.
*
* @Route("rebrickable/colors")
* @Route("colors")
*/
class ColorController extends Controller
{
@ -18,11 +17,9 @@ class ColorController extends Controller
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$colors = $this->get('repository.color')->findAll();
$colors = $em->getRepository(Color::class)->findAll();
return $this->render('rebrickable/color/index.html.twig', [
return $this->render('color/index.html.twig', [
'colors' => $colors,
]);
}

View File

@ -2,7 +2,6 @@
namespace AppBundle\Service\Loader;
use AppBundle\Entity\LDraw\Model;
use AppBundle\Service\StlRendererService;
use League\Flysystem\Filesystem;
@ -25,6 +24,10 @@ class ImageLoader extends BaseLoader
$this->stlRendererService = $stlRendererService;
}
/**
* @param $color
* @param null $path
*/
public function loadColorFromRebrickable($color, $path = null)
{
if(!$path) {
@ -46,23 +49,38 @@ class ImageLoader extends BaseLoader
}
}
public function loadMissingModelImages($color) {
/**
* Load images of models
*
*/
public function loadMissingModelImages() {
$models = $this->em->getRepository(Model::class)->findAll();
$this->initProgressBar(count($models));
foreach ($models as $model) {
$this->progressBar->setMessage($model->getNumber());
if(!$this->mediaFilesystem->has('images'.DIRECTORY_SEPARATOR.$color.DIRECTORY_SEPARATOR.$model->getNumber().'.png')) {
if(!$this->mediaFilesystem->has('images'.DIRECTORY_SEPARATOR.'-1'.DIRECTORY_SEPARATOR.$model->getNumber().'.png')) {
try {
$this->stlRendererService->render(
$this->mediaFilesystem->getAdapter()->getPathPrefix().$model->getPath(),
$this->mediaFilesystem->getAdapter()->getPathPrefix().'images'.DIRECTORY_SEPARATOR.$color.DIRECTORY_SEPARATOR
);
$this->loadModelImage($this->mediaFilesystem->getAdapter()->getPathPrefix().$model->getPath());
} catch (\Exception $e) {
dump($e->getMessage());
}
}
$this->progressBar->advance();
}
$this->progressBar->finish();
}
/**
* Render model and save image into co
*
* @param $file
*/
public function loadModelImage($file) {
$this->stlRendererService->render(
$file,
$this->mediaFilesystem->getAdapter()->getPathPrefix().'images'.DIRECTORY_SEPARATOR.'-1'.DIRECTORY_SEPARATOR
);
}
}