Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Controller;
- use App\Entity\Product;
- use App\Entity\ProductModification;
- use PHPUnit\Util\Json;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing\Annotation\Route;
- class HomeController extends Controller
- {
- /**
- * @Route("/")
- */
- public function home(\Twig_Environment $twig, Request $request)
- {
- $doctrine = $this->getDoctrine();
- $products = $doctrine->getRepository(Product::class)->findAll();
- $products = array_chunk($products, 3);
- $content = $twig->render('product/index.html.twig', ['products' => $products]);
- $response = new Response();
- $response->setContent($content);
- return $response;
- }
- /**
- * @Route("/about")
- */
- public function about(\Twig_Environment $twig)
- {
- $content = $twig->render('other/about.html.twig');
- $response = new Response();
- $response->setContent($content);
- return $response;
- }
- /**
- * @Route("/show/{id}", requirements={"id" = "\d+"})
- * @Method({"GET", "POST"})
- */
- public function show(\Twig_Environment $twig, $id, Request $request)
- {
- //$request = $request->request->getInt('radio');
- $request = $request->request->all();
- var_dump($request);
- $doctrine = $this->getDoctrine();
- $product = $doctrine->getRepository(Product::class)->find($id);
- $modification = $product->getModifications()[0];
- $content = $twig->render('product/show.html.twig', ['product' => $product, 'modification' => $modification]);
- $response = new Response();
- $response->setContent($content);
- return $response;
- }
- /**
- * @Route("/show/{id}/{modification_id}", requirements={"id" = "\d+"})
- * @Method({"GET", "POST"})
- */
- public function showModification(\Twig_Environment $twig, $id, $modification_id)
- {
- $doctrine = $this->getDoctrine();
- $product = $doctrine->getRepository(Product::class)->find($id);
- $modification = $product->getModifications()[0];
- $test = $product->getModifications()[0];
- $test = $doctrine->getRepository(ProductModification::class)->find($modification_id);
- $content = $twig->render('product/showModification.html.twig', ['product' => $product, 'modification' => $modification, 'test' => $test]);
- $response = new Response();
- $response->setContent($content);
- return $response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement