diff --git a/README.md b/README.md
index c8190bc..70cd6af 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,12 @@ A Symfony project
### System requirements
* PHP needs to be a minimum version of PHP 5.5.9
-* PDO
-* SOAP
+* PHP Extensions
+ * FTP
+ * SOAP
+ * PDO
+ * Zip
* *date.timezone* setting set in *php.ini*
-* PHP Zip Extension enabled
* LDView OSMesa >= 4.2.1 [source](https://tcobbs.github.io/ldview/).
You can check if your system meets requirements by running `$ bin/symfony_requirements`
diff --git a/app/Resources/views/part/index.html.twig b/app/Resources/views/part/index.html.twig
new file mode 100644
index 0000000..cef2b6d
--- /dev/null
+++ b/app/Resources/views/part/index.html.twig
@@ -0,0 +1,20 @@
+{% extends 'base.html.twig' %}
+
+
+{% block body %}
+
+
+
+ {% for part in parts %}
+
+ {% endfor %}
+
+
+
+
+ {{ knp_pagination_render(parts) }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/src/AppBundle/Controller/PartController.php b/src/AppBundle/Controller/PartController.php
index cfff17f..0c1acd4 100644
--- a/src/AppBundle/Controller/PartController.php
+++ b/src/AppBundle/Controller/PartController.php
@@ -2,27 +2,54 @@
namespace AppBundle\Controller;
+use AppBundle\Entity\LDraw\Part;
+use Doctrine\DBAL\Query\QueryBuilder;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
/**
- * @Route("/rebrickable/part")
+ * @Route("/parts")
*/
class PartController extends Controller
{
/**
- * @Route("/{id}", name="part_detail")
+ * @Route("/detail/{id}", name="part_detail")
*/
- public function detailAction($id)
+ public function showAction(Request $request, Part $part)
{
- $part = $this->get('manager.rebrickable')->getPart($id);
-
- $em = $this->getDoctrine()->getManager();
- $localPart = $em->getRepository('AppBundle:Part')->findOneBy(['number' => $id]);
-
return $this->render('part/detail.html.twig', [
'part' => $part,
- 'localPart' => $localPart,
+ ]);
+ }
+
+ /**
+ * @Route("/", name="parts_index")
+ */
+ public function indexAction(Request $request)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $queryBuilder = $em->getRepository(Part::class)->createQueryBuilder('p');
+
+ /** @var QueryBuilder $queryBuilder */
+ $queryBuilder->where('p.model is not null');
+
+ $query = $queryBuilder->getQuery();
+
+ $paginator = $this->get('knp_paginator');
+
+ $parts = $paginator->paginate(
+ $query,
+ $request->query->getInt('page', 1)/*page number*/,
+ $request->query->getInt('limit', 30)/*limit per page*/
+ );
+
+ return $this->render('part/index.html.twig', [
+ 'parts' => $parts,
+ 'part' => null
]);
}
}
diff --git a/src/AppBundle/Entity/LDraw/Part.php b/src/AppBundle/Entity/LDraw/Part.php
index d1a8bf6..7eeb1a7 100644
--- a/src/AppBundle/Entity/LDraw/Part.php
+++ b/src/AppBundle/Entity/LDraw/Part.php
@@ -198,6 +198,7 @@ class Part
} elseif ($this->aliasOf) {
return $this->aliasOf->getModel();
}
+ return null;
}
return $this->model;
diff --git a/src/AppBundle/Menu/Builder.php b/src/AppBundle/Menu/Builder.php
index b78814e..e2efc27 100644
--- a/src/AppBundle/Menu/Builder.php
+++ b/src/AppBundle/Menu/Builder.php
@@ -14,6 +14,10 @@ class Builder
'route' => 'homepage',
]);
+ $menu->addChild('Parts', [
+ 'route' => 'parts_index',
+ ]);
+
$menu->addChild('Sets', [
'route' => 'set_browse',
]);