1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-17 04:40:08 -07:00

Remove inventory controller

This commit is contained in:
David Hübner 2017-04-16 22:19:11 +02:00
parent 809b86ce19
commit e5451ff9cd
4 changed files with 35 additions and 68 deletions

View File

@ -1,17 +0,0 @@
<h4 class="ui horizontal divider header">
Sets
</h4>
<div class="ui eight column grid">
{% for inventorySet in inventorySets %}
<div class="column">
<div class="ui fluid bordered image">
<a href="{{ path('rebrickable_set_detail', {number: inventorySet.set}) }}">
<div class="image load">
<img src="{{ inventorySet.set|setImage| imagine_filter('rebrickable_set_min') }}" data-src="{{ inventorySet.set|setImage| imagine_filter('rebrickable_set_min') }}" class="transition visible">
</div>
<div class="ui bottom attached label">{{ inventorySet.set.number }}<br>{{ inventorySet.quantity }}</div>
</a>
</div>
</div>
{% endfor %}
</div>

View File

@ -3,9 +3,6 @@
namespace AppBundle\Controller\Brickset; namespace AppBundle\Controller\Brickset;
use AppBundle\Api\Exception\EmptyResponseException; use AppBundle\Api\Exception\EmptyResponseException;
use AppBundle\Entity\Rebrickable\Color;
use AppBundle\Entity\Rebrickable\Inventory_Part;
use AppBundle\Entity\Rebrickable\Part;
use AppBundle\Entity\Rebrickable\Set; use AppBundle\Entity\Rebrickable\Set;
use AppBundle\Entity\Rebrickable\Theme; use AppBundle\Entity\Rebrickable\Theme;
use AppBundle\Form\FilterSetType; use AppBundle\Form\FilterSetType;
@ -37,7 +34,7 @@ class SetController extends Controller
'subtheme' => $data['subtheme'] ? $data['subtheme']->getSubtheme() : '', 'subtheme' => $data['subtheme'] ? $data['subtheme']->getSubtheme() : '',
'year' => $data['years'] ? $data['years']->getYear() : '', 'year' => $data['years'] ? $data['years']->getYear() : '',
]); ]);
} catch (EmptyResponseException $e) { } catch (EmptyResponseException $e) {
$this->addFlash('warning', 'No set found on '.$e->getService()); $this->addFlash('warning', 'No set found on '.$e->getService());
} catch (\Exception $e) { } catch (\Exception $e) {
$this->addFlash('error', $e->getMessage()); $this->addFlash('error', $e->getMessage());
@ -58,13 +55,13 @@ class SetController extends Controller
$instructions = []; $instructions = [];
try { try {
$instructions = $this->get('api.manager.brickset')->getSetInstructions($id); $instructions = $this->get('api.manager.brickset')->getSetInstructions($id);
} catch (EmptyResponseException $e) { } catch (EmptyResponseException $e) {
// $this->addFlash('warning', 'No instruction found on Brickset.com'); // $this->addFlash('warning', 'No instruction found on Brickset.com');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->addFlash('error', $e->getMessage()); $this->addFlash('error', $e->getMessage());
} }
return $this->render('brickset/instructions.html.twig',[ return $this->render('brickset/instructions.html.twig', [
'instructions' => $instructions, 'instructions' => $instructions,
]); ]);
} }
@ -77,13 +74,13 @@ class SetController extends Controller
$reviews = []; $reviews = [];
try { try {
$reviews = $this->get('api.manager.brickset')->getSetReviews($id); $reviews = $this->get('api.manager.brickset')->getSetReviews($id);
} catch (EmptyResponseException $e) { } catch (EmptyResponseException $e) {
// $this->addFlash('warning', 'No review found on Brickset.com'); // $this->addFlash('warning', 'No review found on Brickset.com');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->addFlash('error', $e->getMessage()); $this->addFlash('error', $e->getMessage());
} }
return $this->render('brickset/reviews.html.twig',[ return $this->render('brickset/reviews.html.twig', [
'reviews' => $reviews, 'reviews' => $reviews,
]); ]);
} }
@ -96,13 +93,13 @@ class SetController extends Controller
$images = []; $images = [];
try { try {
$images = $this->get('api.manager.brickset')->getAdditionalImages($id); $images = $this->get('api.manager.brickset')->getAdditionalImages($id);
} catch (EmptyResponseException $e) { } catch (EmptyResponseException $e) {
// $this->addFlash('warning', 'No images found on Brickset.com'); // $this->addFlash('warning', 'No images found on Brickset.com');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->addFlash('error', $e->getMessage()); $this->addFlash('error', $e->getMessage());
} }
return $this->render('brickset/images.html.twig',[ return $this->render('brickset/images.html.twig', [
'images' => $images, 'images' => $images,
]); ]);
} }

View File

@ -1,37 +0,0 @@
<?php
namespace AppBundle\Controller\Rebrickable;
use AppBundle\Api\Exception\EmptyResponseException;
use AppBundle\Entity\LDraw\Model;
use AppBundle\Entity\Rebrickable\Color;
use AppBundle\Entity\Rebrickable\Inventory;
use AppBundle\Entity\Rebrickable\Inventory_Part;
use AppBundle\Entity\Rebrickable\Inventory_Set;
use AppBundle\Entity\Rebrickable\Part;
use AppBundle\Entity\Rebrickable\Set;
use AppBundle\Entity\Rebrickable\Theme;
use AppBundle\Form\FilterSetType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @Route("/rebrickable/inventory")
*/
class InventoryController extends Controller
{
/**
* @Route("/{number}/inventory_sets", name="rebrickable_inventory_sets")
*/
public function inventoryAction(Inventory $inventory) {
$em = $this->getDoctrine()->getManager();
$inventorySets = $em->getRepository(Set::class)->findAllByInventory($inventory);
return $this->render('rebrickable/set/inventory_sets.html.twig', [
'inventorySets' => $inventorySets,
]);
}
}

View File

@ -3,11 +3,13 @@
namespace AppBundle\Controller\Rebrickable; namespace AppBundle\Controller\Rebrickable;
use AppBundle\Api\Exception\EmptyResponseException; use AppBundle\Api\Exception\EmptyResponseException;
use AppBundle\Entity\Rebrickable\Category;
use AppBundle\Entity\Rebrickable\Part; use AppBundle\Entity\Rebrickable\Part;
use AppBundle\Entity\Rebrickable\Set; use AppBundle\Entity\Rebrickable\Set;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Part controller. * Part controller.
@ -16,6 +18,28 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
*/ */
class PartController extends Controller class PartController extends Controller
{ {
/**
* @Route("/", name="part_index")
*/
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$queryBuilder = $em->getRepository(Part::class)->createQueryBuilder('part');
$queryBuilder->where('part.category = 17');
$paginator = $this->get('knp_paginator');
$sets = $paginator->paginate(
$queryBuilder->getQuery(),
$request->query->getInt('page', 1)/*page number*/,
$request->query->getInt('limit', 30)/*limit per page*/
);
return $this->render(':rebrickable/part:index.html.twig', [
'parts' => $sets,
]);
}
/** /**
* Finds and displays a part entity. * Finds and displays a part entity.
* *
@ -28,7 +52,7 @@ class PartController extends Controller
$apiPart = null; $apiPart = null;
if($part) { if ($part) {
try { try {
$apiPart = $this->get('api.manager.rebrickable')->getPart($part->getNumber()); $apiPart = $this->get('api.manager.rebrickable')->getPart($part->getNumber());
} catch (EmptyResponseException $e) { } catch (EmptyResponseException $e) {