mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-16 20:30:09 -07:00
Add Part index action
This commit is contained in:
parent
ce27f4a672
commit
a1e56ebdd2
@ -5,10 +5,12 @@ A Symfony project
|
|||||||
|
|
||||||
### System requirements
|
### System requirements
|
||||||
* PHP needs to be a minimum version of PHP 5.5.9
|
* PHP needs to be a minimum version of PHP 5.5.9
|
||||||
* PDO
|
* PHP Extensions
|
||||||
|
* FTP
|
||||||
* SOAP
|
* SOAP
|
||||||
|
* PDO
|
||||||
|
* Zip
|
||||||
* *date.timezone* setting set in *php.ini*
|
* *date.timezone* setting set in *php.ini*
|
||||||
* PHP Zip Extension enabled
|
|
||||||
* LDView OSMesa >= 4.2.1 [source](https://tcobbs.github.io/ldview/).
|
* LDView OSMesa >= 4.2.1 [source](https://tcobbs.github.io/ldview/).
|
||||||
|
|
||||||
You can check if your system meets requirements by running `$ bin/symfony_requirements`
|
You can check if your system meets requirements by running `$ bin/symfony_requirements`
|
||||||
|
20
app/Resources/views/part/index.html.twig
Normal file
20
app/Resources/views/part/index.html.twig
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
|
||||||
|
<div style="display: flex; flex-wrap: wrap;">
|
||||||
|
{% for part in parts %}
|
||||||
|
<div style="display: inline-block; width: 160px; margin: 5px; padding: 5px; border: solid 1px gray">
|
||||||
|
<h4><a href="{{ url('part_detail', {id:part.id}) }}">{{ part.id }}</a></h4>
|
||||||
|
<p>{{ part.name }}</p>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="navigation text-center">
|
||||||
|
{{ knp_pagination_render(parts) }}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -2,27 +2,54 @@
|
|||||||
|
|
||||||
namespace AppBundle\Controller;
|
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 Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
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
|
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', [
|
return $this->render('part/detail.html.twig', [
|
||||||
'part' => $part,
|
'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
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,7 @@ class Part
|
|||||||
} elseif ($this->aliasOf) {
|
} elseif ($this->aliasOf) {
|
||||||
return $this->aliasOf->getModel();
|
return $this->aliasOf->getModel();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->model;
|
return $this->model;
|
||||||
|
@ -14,6 +14,10 @@ class Builder
|
|||||||
'route' => 'homepage',
|
'route' => 'homepage',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$menu->addChild('Parts', [
|
||||||
|
'route' => 'parts_index',
|
||||||
|
]);
|
||||||
|
|
||||||
$menu->addChild('Sets', [
|
$menu->addChild('Sets', [
|
||||||
'route' => 'set_browse',
|
'route' => 'set_browse',
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user