diff --git a/app/Resources/views/rebrickable/color/index.html.twig b/app/Resources/views/color/index.html.twig
similarity index 85%
rename from app/Resources/views/rebrickable/color/index.html.twig
rename to app/Resources/views/color/index.html.twig
index 560f9f1..7b6ffac 100644
--- a/app/Resources/views/rebrickable/color/index.html.twig
+++ b/app/Resources/views/color/index.html.twig
@@ -1,5 +1,9 @@
{% extends 'base.html.twig' %}
+{% block title %}{{ 'page.color' | trans }}{% endblock %}
+
+{% block header %}{{ 'page.color' | trans }}{% endblock %}
+
{% block content %}
diff --git a/app/config/service/repository.yml b/app/config/service/repository.yml
index afb69d5..c3330e5 100644
--- a/app/config/service/repository.yml
+++ b/app/config/service/repository.yml
@@ -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]
diff --git a/src/AppBundle/Command/LoadModelImagesCommand.php b/src/AppBundle/Command/LoadModelImagesCommand.php
index d3a2e08..400a0e9 100644
--- a/src/AppBundle/Command/LoadModelImagesCommand.php
+++ b/src/AppBundle/Command/LoadModelImagesCommand.php
@@ -42,7 +42,7 @@ class LoadModelImagesCommand extends ContainerAwareCommand
}
if($input->getOption('models')) {
- $imageLoaderService->loadMissingModelImages($color);
+ $imageLoaderService->loadMissingModelImages();
}
}
}
diff --git a/src/AppBundle/Controller/Rebrickable/ColorController.php b/src/AppBundle/Controller/ColorController.php
similarity index 55%
rename from src/AppBundle/Controller/Rebrickable/ColorController.php
rename to src/AppBundle/Controller/ColorController.php
index 95abc87..298b5d7 100644
--- a/src/AppBundle/Controller/Rebrickable/ColorController.php
+++ b/src/AppBundle/Controller/ColorController.php
@@ -1,15 +1,14 @@
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,
]);
}
diff --git a/src/AppBundle/Service/Loader/ImageLoader.php b/src/AppBundle/Service/Loader/ImageLoader.php
index fd04794..d39f405 100644
--- a/src/AppBundle/Service/Loader/ImageLoader.php
+++ b/src/AppBundle/Service/Loader/ImageLoader.php
@@ -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
+ );
}
}
\ No newline at end of file