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

Show model data in template

This commit is contained in:
David Hübner 2017-01-17 18:36:15 +01:00
parent 39f69d2110
commit 27210e650c
9 changed files with 43 additions and 36 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,4 +4,8 @@
{{ dump(part) }}
{{ dump(localPart) }}
{{ dump(model) }}
{% endblock %}

View File

@ -3,7 +3,7 @@
# To use this hook you need to install php-cs-fixer
# Copy this file to ./git/hooks/pre-commit to get it working.
ROOT="/"
ROOT=""
echo "php-cs-fixer pre commit hook start"
@ -16,7 +16,7 @@ fi
if $HAS_PHP_CS_FIXER; then
git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
$PHP_CS_FIXER fix --config-file=$ROOT/.php_cs --verbose "$line";
$PHP_CS_FIXER fix --config=$ROOT/.php_cs --verbose "$line";
git add "$line";
done
else

View File

@ -0,0 +1,30 @@
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* @Route("rebrickable/part")
*/
class PartController extends Controller
{
/**
* @Route("/{id}", name="part_detail")
*/
public function detailAction($id)
{
$part = $this->get('manager.rebrickable')->getPart($id);
$em = $this->getDoctrine()->getManager();
$localPart = $em->getRepository('AppBundle:Part')->findBy(['id' => $id]);
$model = $em->getRepository('AppBundle:Model')->findBy(['number' => $id]);
return $this->render('part/detail.html.twig', [
'part' => $part,
'localPart' => $localPart,
'model' => $model,
]);
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* @Route("rebrickable/parts")
*/
class PartsController extends Controller
{
/**
* @Route("/{id}", name="part_detail")
*/
public function detailAction($id)
{
$part = $this->get('manager.rebrickable')->getPartById($id);
return $this->render('parts/detail.html.twig', [
'part' => $part,
]);
}
}

View File

@ -8,12 +8,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* @Route("/brickset/sets")
* @Route("/brickset/set")
*/
class SetsController extends Controller
class SetController extends Controller
{
/**
* @Route("/", name="sets_browse")
* @Route("/", name="set_browse")
*/
public function browseAction(Request $request)
{
@ -32,7 +32,7 @@ class SetsController extends Controller
]);
}
return $this->render('sets/browse.html.twig', [
return $this->render('set/browse.html.twig', [
'form' => $form->createView(),
'sets' => $sets,
]);
@ -45,11 +45,8 @@ class SetsController extends Controller
{
$set = $this->get('manager.brickset')->getSetById($id);
$parts = $this->get('sevice.collection')->getSet($set->getNumber().'-'.$set->getNumberVariant())->getParts();
return $this->render('sets/detail.html.twig', [
return $this->render('set/detail.html.twig', [
'set' => $set,
'parts' => $parts,
]);
}
}

View File

@ -15,7 +15,7 @@ class Builder
]);
$menu->addChild('Sets', [
'route' => 'sets_browse',
'route' => 'set_browse',
]);
return $menu;