65 lines
1.9KB

  1. <?php
  2. namespace Lc\ShopBundle\Controller\Frontend ;
  3. use App\Form\Frontend\OrderProductsType;
  4. use CKSource\CKFinder\Response\JsonResponse;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Lc\ShopBundle\Context\MerchantUtilsInterface;
  7. use Lc\ShopBundle\Context\ProductFamilyInterface;
  8. use Symfony\Component\HttpFoundation\Request;
  9. class CartController extends BaseController
  10. {
  11. protected $productFamilyRepository ;
  12. public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils)
  13. {
  14. parent::__construct($em, $merchantUtils);
  15. $this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ;
  16. }
  17. public function addProductFamily(Request $request)
  18. {
  19. $return = [] ;
  20. $data = $request->request->all() ;
  21. $return = $data ;
  22. if(isset($data['order_products']['id_product_family'])) {
  23. $idProductFamily = $data['order_products']['id_product_family'] ;
  24. $productFamily = $this->productFamilyRepository->find($idProductFamily) ;
  25. if($productFamily) {
  26. $form = $this->createForm(OrderProductsType::class, ['id_product_family' => $productFamily->getId()]);
  27. $form->handleRequest($request);
  28. if ($form->isSubmitted() && $form->isValid()) {
  29. }
  30. }
  31. }
  32. return new JsonResponse($return) ;
  33. }
  34. public function addProduct()
  35. {
  36. }
  37. public function editProduct()
  38. {
  39. }
  40. public function deleteProduct()
  41. {
  42. }
  43. public function summary()
  44. {
  45. }
  46. }