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:
parent
328d14426e
commit
7e31eee729
@ -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">
|
@ -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]
|
||||
|
@ -42,7 +42,7 @@ class LoadModelImagesCommand extends ContainerAwareCommand
|
||||
}
|
||||
|
||||
if($input->getOption('models')) {
|
||||
$imageLoaderService->loadMissingModelImages($color);
|
||||
$imageLoaderService->loadMissingModelImages();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
]);
|
||||
}
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user