ソースを参照

Ajout au panier : formulaire et structure

reduction
Guillaume 4年前
コミット
030fda1c2e
3個のファイルの変更104行の追加0行の削除
  1. +20
    -0
      ShopBundle/Controller/Frontend/BaseController.php
  2. +64
    -0
      ShopBundle/Controller/Frontend/CartController.php
  3. +20
    -0
      ShopBundle/Resources/config/shop_routes.yaml

+ 20
- 0
ShopBundle/Controller/Frontend/BaseController.php ファイルの表示

@@ -0,0 +1,20 @@
<?php

namespace Lc\ShopBundle\Controller\Frontend ;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class BaseController extends AbstractController
{
protected $em ;
protected $globalParam ;

public function __construct(EntityManagerInterface $em, GlobalParamInterface $globalParam)
{
$this->em = $em ;
$this->globalParam = $globalParam ;
}

}

+ 64
- 0
ShopBundle/Controller/Frontend/CartController.php ファイルの表示

@@ -0,0 +1,64 @@
<?php

namespace Lc\ShopBundle\Controller\Frontend ;

use App\Form\Frontend\OrderProductsType;
use CKSource\CKFinder\Response\JsonResponse;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Symfony\Component\HttpFoundation\Request;

class CartController extends BaseController
{
protected $productFamilyRepository ;

public function __construct(EntityManagerInterface $em, GlobalParamInterface $globalParam)
{
parent::__construct($em, $globalParam);
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ;
}

public function addProductFamily(Request $request)
{
$return = [] ;
$data = $request->request->all() ;
$return = $data ;
if(isset($data['order_products']['id_product_family'])) {
$idProductFamily = $data['order_products']['id_product_family'] ;
$productFamily = $this->productFamilyRepository->find($idProductFamily) ;

if($productFamily) {

$form = $this->createForm(OrderProductsType::class, ['id_product_family' => $productFamily->getId()]);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

}
}
}

return new JsonResponse($return) ;
}

public function addProduct()
{

}

public function editProduct()
{

}

public function deleteProduct()
{

}

public function summary()
{

}
}

+ 20
- 0
ShopBundle/Resources/config/shop_routes.yaml ファイルの表示

@@ -6,3 +6,23 @@ admin_switch_merchant:
lc_api:
path: /api/{entity}/{id}
controller: Lc\ShopBundle\Controller\ApiController::getEntity

lc_frontend_cart_add_product_family:
path: /cart/add-product-family
controller: Lc\ShopBundle\Controller\Frontend\CartController::addProductFamily

lc_frontend_cart_add_product:
path: /cart/add-product
controller: Lc\ShopBundle\Controller\Frontend\CartController::addProduct

lc_frontend_cart_edit_product:
path: /cart/edit-product
controller: Lc\ShopBundle\Controller\Frontend\CartController::editProduct

lc_frontend_cart_delete_product:
path: /cart/delete-product
controller: Lc\ShopBundle\Controller\Frontend\CartController::deleteProduct

lc_frontend_cart_summary:
path: /cart/summary
controller: Lc\ShopBundle\Controller\Frontend\CartController::summary

読み込み中…
キャンセル
保存