From 00d455210dc27012433e58ab3fbf82644ace876e Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 2 Jun 2017 03:24:49 +0200 Subject: [PATCH] Move PartController --- app/Resources/views/part/detail.html.twig | 66 +++++++++++++++ .../views/rebrickable/part/detail.html.twig | 81 ------------------- .../{Rebrickable => }/PartController.php | 18 ++--- 3 files changed, 74 insertions(+), 91 deletions(-) create mode 100644 app/Resources/views/part/detail.html.twig delete mode 100644 app/Resources/views/rebrickable/part/detail.html.twig rename src/AppBundle/Controller/{Rebrickable => }/PartController.php (71%) diff --git a/app/Resources/views/part/detail.html.twig b/app/Resources/views/part/detail.html.twig new file mode 100644 index 0000000..71b303a --- /dev/null +++ b/app/Resources/views/part/detail.html.twig @@ -0,0 +1,66 @@ +{% extends 'base.html.twig' %} + +{% import 'macros/blocks.html.twig' as blocks %} + +{% block header %}{{ part.name }}{% endblock %} + +{% block content %} +
+
+
+
+
+ {{ blocks.partImage(part.id,'part_large') }} +
+
+
+
+ + + + + + + + + + + + + + + {% if apiPart %} + + + + + + + + + + + + + {% endif %} +
{{ 'part.id' | trans }}

{{ part.id}}

{{ 'part.name' | trans }}{{ part.name}}
{{ 'part.category' | trans }}{{ part.category ? part.category.name }}
{{ 'part.model' | trans }} + {% if part.model %} + {{ part.model.id }} + {% endif %} +
{{ 'part.alternates' | trans }} + {% for alternate in apiPart.alternates %} + {{ alternate }} + {% endfor %} +
{{ 'part.molds' | trans }} + {% for mold in apiPart.molds %} + {{ mold }} + {% endfor %} +
Rebrickable
+ + {{ 'model.empty'|trans }} +
+
+
+
+
+{% endblock %} diff --git a/app/Resources/views/rebrickable/part/detail.html.twig b/app/Resources/views/rebrickable/part/detail.html.twig deleted file mode 100644 index de7056f..0000000 --- a/app/Resources/views/rebrickable/part/detail.html.twig +++ /dev/null @@ -1,81 +0,0 @@ -{% extends 'base.html.twig' %} - -{% import 'macros/blocks.html.twig' as blocks %} - -{% block header %}{{ part.name }}{% endblock %} - -{% block content %} -
-
-
- {{ blocks.partImage(part.id,'part_large') }} -
-
-
-
- - - - - - - - - - - - - - - {% if apiPart %} - - - - - - - - - - - - - - - - - {% endif %} -
{{ 'part.id' | trans }}

{{ part.id}}

{{ 'part.name' | trans }}{{ part.name}}
{{ 'part.category' | trans }}{{ part.category ? part.category.name }}
{{ 'part.model' | trans }} - {% if part.model %} - {{ part.model.id }} - {% endif %} -
{{ 'part.alternates' | trans }} - {% for alternate in apiPart.alternates %} - {{ alternate }} - {% endfor %} -
{{ 'part.molds' | trans }} - {% for mold in apiPart.molds %} - {{ mold }} - {% endfor %} -
{{ 'part.prints' | trans }} - {% for mold in apiPart.prints %} - {{ mold }} - {% endfor %} -
Rebrickable
-
-
-
- - {#
#} - {#

#} - {# Sets#} - {#

#} - - {#
#} - {#{% for set in sets %}#} - {#{{ blocks.set(set) }}#} - {#{% endfor %}#} - {#
#} - {#
#} - -{% endblock %} diff --git a/src/AppBundle/Controller/Rebrickable/PartController.php b/src/AppBundle/Controller/PartController.php similarity index 71% rename from src/AppBundle/Controller/Rebrickable/PartController.php rename to src/AppBundle/Controller/PartController.php index 870b481..1a9e142 100644 --- a/src/AppBundle/Controller/Rebrickable/PartController.php +++ b/src/AppBundle/Controller/PartController.php @@ -1,6 +1,6 @@ getDoctrine()->getManager(); - $apiPart = null; - if ($part) { + if($model = $part->getModel()) { + $this->redirectToRoute('model_detail',['id' => $model->getId()]); + } + try { $apiPart = $this->get('api.manager.rebrickable')->getPart($part->getId()); } catch (EmptyResponseException $e) { @@ -35,12 +36,9 @@ class PartController extends Controller $this->addFlash('error', $e->getMessage()); } - $sets = $part != null ? $em->getRepository(Set::class)->findAllByPartNumber($part->getId()) : null; - - return $this->render('rebrickable/part/detail.html.twig', [ + return $this->render('part/detail.html.twig', [ 'part' => $part, 'apiPart' => $apiPart, - 'sets' => $sets, ]); }