app/Customize/Controller/AjaxController.php line 622

Open in your IDE?
  1. <?php
  2. /**
  3.  * @version EC-CUBE4系
  4.  * @copyright 株式会社 翔 kakeru.co.jp
  5.  *
  6.  * 2022年01月15日カスタマイズ
  7.  *
  8.  * app\Customize\Controller\AjaxController.php
  9.  *
  10.  *
  11.  * LM側のセキュリティテーブルを読み込み
  12.  * TYPE で作業を行う
  13.  *
  14.  *
  15.  *                                        ≡≡≡┏(^o^)┛
  16.  *****************************************************/
  17. namespace Customize\Controller;
  18. use Customize\Event\LmEvents;
  19. use Customize\Service\AmountCalculationService;
  20. use Customize\Service\EstimateCharacterizer;
  21. use Customize\Service\GoodsService;
  22. use Eccube\Controller\AbstractController;
  23. use Lm\Engine\EC\Entity\CategoryWithRelated;
  24. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  25. use Symfony\Component\HttpFoundation\JsonResponse;
  26. use Symfony\Component\HttpFoundation\Request;
  27. use Symfony\Component\Routing\Annotation\Route;
  28. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  29. #use Symfony\Component\DependencyInjection\ContainerInterface;
  30. #use Symfony\Component\HttpFoundation\RequestStack;
  31. use Symfony\Component\Validator\Validator\ValidatorInterface;
  32. use Symfony\Component\Validator\Constraints as Assert;
  33. use Customize\Service\AutoLoadService;
  34. use Customize\Service\OrderHelper;
  35. use Customize\Service\CartService;
  36. use Customize\Converter\OrderConverter;
  37. use Customize\Service\CommonService;
  38. use Lm\Service\Db\SqlService;
  39. use Customize\Validator as Varid;
  40. use Customize\Converter\EstimateConverter;
  41. use Eccube\Repository\ProductClassRepository;
  42. use Lm\Service\Store\FileStoreService;
  43. use Customize\Service\LmHelper;
  44. use Customize\Service\CustomerService;
  45. use Customize\Service\MobileDetector as LmMobileDetector;
  46. #use Error;
  47. use Eccube\Repository\CartItemRepository;
  48. class AjaxController extends AbstractController
  49. {
  50.     const Token_Name 'AjaxToken';
  51.     const Coupon_Table  'coupon_campaign_table';
  52.     const History_Table 'coupon_history_table';
  53.     const Estimate_name 'estimate';
  54.     const TMP_DIR 'front-public/images/tmp_img/';
  55.     protected $OrderConverter;
  56.     protected $OrderHelper;
  57.     protected $AutoLoadService;
  58.     protected $CommonService;
  59.     protected $CartService;
  60.     protected $Validator;
  61.     protected $EstimateConverter;
  62.     protected $Errors = [];
  63.     protected $ProductClassRepository;
  64.     protected $ProductClass;
  65.     protected $ImageFiles =[];
  66.     protected $CartItemRepository;
  67.     /**
  68.      * @var EstimateCharacterizer
  69.      */
  70.     private $EstimateCharacterizer;
  71.     private $customerService;
  72.     /**
  73.      * @var LmMobileDetector
  74.      */
  75.     private $mobileDetector;
  76.     public function __construct(
  77.     //    ContainerInterface $Container
  78.    //     ,RequestStack       $RequestStack
  79.         OrderConverter         $OrderConverter,
  80.         AutoLoadService        $AutoLoadService,
  81.         CommonService          $CommonService,
  82.         OrderHelper            $OrderHelper,
  83.         CartService            $CartService,
  84.         ValidatorInterface     $Validator,
  85.         EstimateConverter      $EstimateConverter,
  86.         ProductClassRepository $ProductClassRepository,
  87.         CartItemRepository     $CartItemRepository,
  88.         GoodsService           $GoodsService,
  89.         EstimateCharacterizer  $EstimateCharacterizer,
  90.         CustomerService        $customerService,
  91.         LmMobileDetector       $mobileDetector
  92.     )
  93.     {
  94.         $this->AutoLoadService $AutoLoadService;
  95.         $this->OrderConverter  $OrderConverter;
  96.         $this->CommonService   $CommonService;
  97.         $this->OrderHelper     $OrderHelper;
  98.         $this->CartService     $CartService;
  99.         $this->Validator       $Validator;
  100.         $this->EstimateConverter $EstimateConverter;
  101.         $this->ProductClassRepository $ProductClassRepository;
  102.         $this->CartItemRepository $CartItemRepository;
  103.         $this->GoodsService $GoodsService;
  104.         $this->EstimateCharacterizer $EstimateCharacterizer;
  105.         $this->customerService $customerService;
  106.         $this->mobileDetector $mobileDetector;
  107.     }
  108.     /**
  109.      * 成り代わり 識別入力設定Data を セットする
  110.      * mode =clos 閉じる
  111.      * @Route("/Ajax/NarikawariDataSet/{Token}", name="Ajax_NarikawariDataSet", methods={"POST"}, requirements={"Token" = "\w+"})
  112.      */
  113.     public function NarikawariDataSet(Request $request$Token null)
  114.     {
  115.         $Sessions $this->AutoLoadService->GetNariKawariSession();
  116.         if ($Token != $Sessions['token']) {
  117.             throw new NotFoundHttpException();
  118.         }
  119.         if (!'close' == $request->request->get('mode')) {
  120.             if (!$Datas $request->request->get('NariKawari')) {
  121.                 throw new NotFoundHttpException();
  122.             }
  123.             $Sessions $this->session->get(AutoLoadService::NARIKAWARI_SESSON);
  124.             foreach ($Datas as $Column => $Data) {
  125.                 switch ($Column) {
  126.                     case 'fax_no':
  127.                         if (!is_numeric(str_replace('-'''$Data))) {
  128.                             $Data '';
  129.                         }
  130.                         break;
  131.                     case ('fusen'):
  132.                         if (is_array($Data)){
  133.                             $Id array_key_first($Data) ;
  134. #                            $this->OrderConverter->SetFusen($Id,$Data[$Id]);
  135.                         }
  136.                     break;
  137.                     default:
  138.                         break;
  139.                 }
  140.                 $Sessions[$Column] = $Data;
  141.             }
  142.         }
  143.         $Sessions['show_flg']=false;
  144.         $this->session->set(AutoLoadService::NARIKAWARI_SESSON$Sessions);
  145.         return $this->json(['done' => true]);
  146.     }
  147.     /**
  148.      * 成り代わり 識別入力設定Data を セットする
  149.      * mode =clos 閉じる
  150.      * @Route("/Ajax/CouponJdge/{Token}", name="Ajax_CouponJdge", methods={"POST"}, requirements={"Token" = "\w+"})
  151.      */
  152.     public function CouponJdge(Request $request$Token null){
  153.          if($Token != $this->CommonService->GetToken('CouponJdge')){
  154.             return $this->json(['status' => 'NG'], 400);
  155.             //throw new NotFoundHttpException();
  156.         }
  157.         $CouponCd  $request->request->get('CouponCd');
  158.         if(!preg_match('/'$this->CommonService->GetConfig('CouponCode_Regex').'/',$CouponCd)){
  159.             return $this->json(['status' => 'NG','message'=>trans('Common.coupon_messege03')]);
  160.         }
  161.         $Sql= new SqlService();
  162.             $Coupon $Sql->Table(self::Coupon_Table)
  163.                         ->set('coupon_campaign_code' ,$CouponCd)
  164.                         ->Set('coupon_campaign_ddate','NULL')
  165.                         ->Find();
  166.         #クーポンがない
  167.         if(!$Coupon){
  168.             return $this->json(['status' => 'NG','message'=>trans('Common.coupon_messege03')]);
  169.         }
  170.          #LNOrderOptin の初期化
  171.         $this->CommonService->InitializeLmOrderOption(CommonService::Lm_Option_Coupon);
  172.         #期間がおかしい
  173.         if($Coupon['coupon_campaign_start_date'] > date('Y-m-d') || $Coupon['coupon_campaign_end_date'] < date('Y-m-d')){
  174.             return $this->json(['status' => 'NG','message'=>trans('Common.coupon_messege04') .' '.$Coupon['coupon_campaign_start_date'].'〜'.$Coupon['coupon_campaign_end_date']]);
  175.         }
  176.         #未使用
  177.         $Customer $this->getUser();
  178.             $History $Sql->Table(self::History_Table)
  179.                            ->Set('coupon_history_campaign_id',$Coupon['coupon_campaign_id'])
  180.                            ->Set('coupon_history_customer_id',$Customer->getLmCustomerId())
  181.                            ->Find();
  182.         if ($History){
  183.             return $this->json(['status' => 'NG','message'=>trans('Common.coupon_messege05') .' '.$History['coupon_history_cdate']]);
  184.         }
  185.         #金額
  186.         $preOrderId $this->CartService->getPreOrderId();
  187.         $Order $this->OrderHelper->getPurchaseProcessingOrder($preOrderId);
  188.         if($Coupon['coupon_campaign_price'] > $Order->getProductTotal()){
  189.             $Messege=str_replace('@@@',$Coupon['coupon_campaign_price'], trans('Common.coupon_messege06'));
  190.             return $this->json(['status' => 'NG','message'=>$Messege ]);
  191.         }
  192.         #LnOrderOprionに登録する
  193.         $this->CommonService->AddLmOrderOption(CommonService::Lm_Option_Coupon,$Coupon);
  194.         #全て正常終了
  195.         return $this->json(['status' => 'OK' ]);
  196.     }
  197.     //@Route("/ajax/amount-calculation", name="Ajax_CouponJdge", methods={"POST", "GET"})
  198.     /**
  199.      * TODO: 金額計算API
  200.      * TODO: トークン?
  201.      * TODO: methods={"GET"}はリリース時には削除のこと
  202.      *
  203.      * @param Request $request
  204.      * @param AmountCalculationService $amountCalculationService
  205.      *
  206.      *
  207.      * @return \Symfony\Component\HttpFoundation\JsonResponse
  208.      */
  209.     public function amountCalculation(Request $requestAmountCalculationService $amountCalculationService)
  210.     {
  211.         //
  212.         $data $request->get('data', []);
  213.         //
  214.         $result $amountCalculationService->calculate($data);
  215.         //
  216.         return $this->json([
  217.             'status' => 'OK',
  218.             'result' => $result,
  219.         ]);
  220.     }
  221.     /**
  222.      * @Route("/ajax/show-goods-size-list-pull-down-by-color", name="ajax_show-goods-size-list-pull-down-by-color", methods={"POST"} )
  223.      * @Template("Ajax/size-list.twig")
  224.      */
  225.     public function showCartItemSizePullDownByColor(Request $request)
  226.     {
  227.         $context = [
  228.             'ItemId' => $request->get('ItemId'),
  229.             'ProductId' => $request->get('ProductId'),
  230.             'ClassCategory2Id' => $request->get('ClassCategory2Id'),
  231.             'ClassCategory1Id' => $request->get('ClassCategory1Id'),
  232.             'EstimateId' => $request->get('EstimateId'),
  233.         ];
  234.         return $context;
  235.     }
  236.     /**
  237.      * @Route("/ajax/show-goods-color-list-pull-down-by-size", name="ajax_show-goods-color-list-pull-down-by-size", methods={"POST"} )
  238.      * @Template("Ajax/color-list.twig")
  239.      */
  240.     public function showCartItemColorPullDownBySize(Request $request)
  241.     {
  242.         $context = [
  243.             'ItemId' => $request->get('ItemId'),
  244.             'ProductId' => $request->get('ProductId'),
  245.             'ClassCategory2Id' => $request->get('ClassCategory2Id'),
  246.             'ClassCategory1Id' => $request->get('ClassCategory1Id'),
  247.             'EstimateId' => $request->get('EstimateId')
  248.         ];
  249.         return $context;
  250.     }
  251.     /**
  252.      * @Route("/ajax/show-stock-label", name="ajax_show-stock-label", methods={"GET", "POST"} )
  253.      * @Template("Ajax/stock-label.twig")
  254.      */
  255.     public function showStockLabel(Request $request)
  256.     {
  257.         $context = [
  258.             'ProductId' => $request->get('ProductId'),
  259.             'ClassCategory1Id' => $request->get('ClassCategory1Id'),
  260.             'ClassCategory2Id' => $request->get('ClassCategory2Id'),
  261.         ];
  262.         return $context;
  263.     }
  264.    /**
  265.     * 見積もりシミュレーションで バリデーションする
  266.     *
  267.     * @Route("/Ajax/estimate", name="Ajax_estimate", methods={"GET","POST"} )
  268.     */
  269.     public function EstimatetValids(Request $request){
  270.         if ($this->CommonService->GetToken(CommonService::Matrix_Token) != $request->get('OlToken') ){
  271.             throw new NotFoundHttpException();
  272.         }
  273.         $Estimate $request->get(self::Estimate_name);
  274.         //$_SESSION['data'][]=$Estimate;
  275.        // $File = $request->files->get('estimate');
  276.             $this->EstimatetValidPrint($Estimate);
  277.             $this->EstimatetValidSusoage($Estimate);
  278.             $this->EstimatetValidImage($Estimate,$request->files->get(self::Estimate_name));
  279.         if (count($this->Errors)>0){
  280.             $Token =$this->CommonService->ResetToken(CommonService::Matrix_Token);
  281.             return $this->json(['status' => 'Error','OlToken'=> $Token,'Errors'=> $this->Errors ]);
  282.         }else{
  283.             return $this->json(['status' => 'OK','FileName'=>$this->ImageFiles]);
  284.         }
  285.     }
  286.     protected function EstimatetValidPrint($Estimate){
  287.         if (!= ($Estimate['type'] ?? )) {return ;}
  288.         $GetMessage = function ($i){
  289.             return trans('front.estimatet.Error' str_pad($i,2,0,STR_PAD_LEFT));
  290.         };
  291.         $tateMax 9999;
  292.         $yokoMax 9999;
  293.             if($ProductClassId $Estimate['product_class_id'] ?? null ){
  294.             $goods $this->GoodsService->getGoodsByJanId($ProductClassId);
  295.                 $tenshaDetailList $this->EstimateConverter->getTenshaDetailListById($goods['goods_tensha']);
  296.                 if($tenshaDetailList && isset($tenshaDetailList[0]['tensha_tate']) && isset($tenshaDetailList[0]['tensha_yoko'])) {
  297.                     $Yohaku $this->CommonService->GetConfig('ESTIMATE_YOHAKU');
  298.                     $tateMax $tenshaDetailList[0]['tensha_tate'] - $Yohaku ?? 9999;
  299.                     $yokoMax $tenshaDetailList[0]['tensha_yoko'] - $Yohaku ?? 9999;
  300.                 }
  301.             }
  302.         $Error $this->Validator->validate(
  303.             ($Estimate['type'] ?? ),
  304.             [
  305.                 new Varid\Estimate(['Estimate'=>$Estimate,
  306.                                     'TateMax' => $tateMax,
  307.                                     'YokoMax' => $yokoMax,
  308.             ]),
  309.             ]
  310.             );
  311.         if ($Error->count()<1){return [];}
  312.             $Re=[];
  313.             foreach (json_decode($Error[0]->getMessage(),true) as $key => $Errors){
  314.                 if (!is_array($Error)<1){
  315.                     $Re[] = $GetMessage($Errors);
  316.                     continue;
  317.                 }
  318.                 foreach ($Errors as $i){
  319.                     $line $key .'行目 ';
  320.                     $Message $GetMessage($i);
  321.                     switch($i){
  322.                         case 13:
  323.                             $Message str_replace('@TATE',$tateMax,$Message);
  324.                             $Message str_replace('@YOKO',$yokoMax,$Message);
  325.                         break;
  326.                     }
  327.                     $Re[] = $line $Message;
  328.                 }
  329.             }
  330.             $this->Errors $Re;
  331.             return ;
  332.     }
  333.     protected function EstimatetValidSusoage($Estimate){
  334.         if (!= ($Estimate['type'] ?? )) {return ;}
  335.         $Config $this->CommonService->GetConfig('EstimatetValid');
  336.         $Max    $Config['SUSOAGE_NAME_MAX'];
  337.         $Message str_replace('@MAX',$Max,trans('front.estimatet.Error14') );
  338.         $Susoages =$Estimate['susoage'] ?? [];
  339.         foreach ($Susoages as $ProductClassId  => $Susoage){
  340.             foreach ($Susoage as $i => $Value){
  341.                 if (!$Value['do']){continue;}
  342.                 if (!$Name $Value['name']?? null){continue;}
  343.             $Error $this->Validator->validate(
  344.                 $Name,
  345.                 [
  346.                     new Assert\Length(
  347.                             ['max' => $Max,
  348.                              'maxMessage' => $Message
  349.                         ]),
  350.                     ]);
  351.                 if(count($Error)){
  352.                     $ProductClass =  $this->CartService->GetProductClass($ProductClassId);
  353.                     $ClassCategoryName=[1=>''2=>''];
  354.                     if ($ClassCategory1 $ProductClass->getClassCategory1()){
  355.                         $ClassCategoryName[1] = $ClassCategory1->getName() . ' : ';
  356.                     }
  357.                     if ($ClassCategory2 $ProductClass->getClassCategory2()){
  358.                         $ClassCategoryName[2] = $ClassCategory2->getName() .' : ';
  359.                     }
  360.                     $Line = ($i ) .'行目 ';
  361.                    $this->Errors[] = $ClassCategoryName[1] . $ClassCategoryName[2]. $Line$Error[0]->getMessage();
  362.                 }
  363.             }
  364.         }
  365.         return ;
  366.     }
  367.     protected function EstimatetValidImage($Estimate,$Files){
  368.         if (!= ($Estimate['type'] ?? )) {return ;}
  369.         $Valid $this->CommonService->GetConfig('EstimatetValid');
  370.         $CompanyName $this->CommonService->BaseInfo('CompanyName');
  371.         foreach ($Files as $i => $File) {
  372.             if (filesize($File) > ((env('ESTIMATE_IMAGE_SIZE') ?? 10) * 1024 1024)) {
  373.                 return $this->Errors[] = "ファイル容量が大き過ぎます。";
  374.             }
  375.         }
  376.         $s3 = new FileStoreService(env('S3_LM_DOC'), self::TMP_DIR);
  377.         $date date('YmdHis');
  378.         foreach ($Files as $i => $File){
  379.             if ($File){
  380.                 $kaku $File->getClientOriginalExtension();
  381.                 $code substr(str_pad(mt_rand(0,99999999),8,0,STR_PAD_LEFT),-4);
  382.                 $newFilename $date.$code.'.'.$kaku;
  383.                 $this->ImageFiles[$i]['name'] = $File->getClientOriginalName();
  384.                 $this->ImageFiles[$i]['tmp_name'] = $newFilename;
  385.                 // S3へファイルアップロード
  386.                 $s3->uploadFile($newFilename$File->getPathname());
  387.             }
  388.             $Error $this->Validator->validate(
  389.                 $File,
  390.                 [
  391.                     new Varid\EstimateImage([
  392.                         'allowExtensions' => $Valid['IMAGE_EXT'],
  393.                     ])
  394.                 ]);
  395.             if(count($Error)){
  396.                 if ($Message $Error[0]->getMessage()){
  397.                     $Message str_replace('@LINE',$i $Message );
  398.                     $Message str_replace('@CompanyName',$CompanyName,$Message);
  399.                 $this->Errors[] = $Message;
  400.                 }
  401.             }
  402.         }
  403.         return ;
  404.     }
  405.    /**
  406.     * 見積もりシミュレーションで DATAを文字化する
  407.     *
  408.     * @Route("/Ajax/estimate_character", name="Ajax_Estimate_Character", methods={"GET","POST"} )
  409.     * @Template("Estimate/Parts/Chara.twig")
  410.     */
  411.     public function EstimateCharacter(Request $request){
  412.         $isMobile $this->mobileDetector->isMobile();
  413.         $Estimate $request->get(self::Estimate_name);
  414.         
  415.         // Get cart items for campaign discount calculation (fallback to session estimate products)
  416.         try {
  417.             $didSet false;
  418.             $carts $this->CartService->getCarts();
  419.             if (!empty($carts)) {
  420.                 $CartItems $this->CartItemRepository->findBy(['Cart' => $carts]);
  421.                 if (!empty($CartItems)) {
  422.                     // Calculate campaign discount from real cart items
  423.                     $this->EstimateCharacterizer->SetEstimateOption($CartItems, [], 'cart');
  424.                     $didSet true;
  425.                 }
  426.             }
  427.             if (!$didSet) {
  428.                 // Fallback: build lightweight items from session 'estimate_products'
  429.                 $products $this->get('session')->get('estimate_products', []);
  430.                 if (is_array($products) && !empty($products)) {
  431.                     $fakeItems = [];
  432.                     $pcs $this->ProductClassRepository->findBy(['id' => array_keys($products)]);
  433.                     foreach ($pcs as $pc) {
  434.                         $qty = (int)($products[$pc->getId()] ?? 0);
  435.                         if ($qty <= 0) { continue; }
  436.                         // Minimal adapter exposing getProductClass/getQuantity/getPriceIncTax
  437.                         $fakeItems[] = new class($pc$qty) {
  438.                             private $pc; private $qty;
  439.                             public function __construct($pc$qty){ $this->pc=$pc$this->qty=$qty; }
  440.                             public function getProductClass(){ return $this->pc; }
  441.                             public function getQuantity(){ return $this->qty; }
  442.                             public function getPriceIncTax(){ return method_exists($this->pc,'getPrice02IncTax') ? (int)$this->pc->getPrice02IncTax() : 0; }
  443.                         };
  444.                     }
  445.                     if (!empty($fakeItems)) {
  446.                         $this->EstimateCharacterizer->SetEstimateOption($fakeItems, [], 'estimate');
  447.                     }
  448.                 }
  449.             }
  450.         } catch (\Throwable $e) {
  451.             error_log("DEBUG: Error in SetEstimateOption: " $e->getMessage());
  452.         }
  453.         try {
  454.             $this->EstimateCharacterizer->EstimateCharacterIzation($Estimate);
  455.         } catch (\Throwable $e) {
  456.             error_log("DEBUG: EstimateCharacterIzation error: " $e->getMessage());
  457.             return;
  458.         }
  459.         $characters $this->EstimateCharacterizer->GetCharacters();
  460.         $campaignDiscount $this->EstimateCharacterizer->GetCampaignDiscount();
  461.         $campaignDetails $this->EstimateCharacterizer->GetCampaignDetails();
  462.         return [
  463.            'EstimateOptions' => $characters,
  464.            'CampaignDiscount' => $campaignDiscount,
  465.            'CampaignDetails' => $campaignDetails,
  466.            'isMobile' => $isMobile
  467.         ];
  468.     }
  469.     /**
  470.      * Handle Karte when user click phone on any screen
  471.      *
  472.      * @Route("/Ajax/karte_phone", name="ajax_karte_tel_inquiry", methods={"POST"})
  473.      */
  474.     public function ajaxKartePhoneRequest(Request $request)
  475.     {
  476.         $lmCustomer null;
  477.         $customer $this->getUser();
  478.         if (!empty($customer)) {
  479.             $lmCustomer $this->customerService->GetLandMarkCustomerId($customer->getLmCustomerId());
  480.         }
  481.         $fromUrl $request->get('fromUrl''');
  482.         $karte['telephone_inquiry'] = [
  483.             'from_url' => $fromUrl,
  484.             'email' => empty($lmCustomer) ? "" $lmCustomer['customer_mail']
  485.         ];
  486.         $templateContent $this->renderView('Karte/telephone_inquiry.twig', [
  487.             'Karte' => $karte,
  488.         ]);
  489.         $response = [
  490.             'status' => 200,
  491.             'message' => 'Process completed successfully.',
  492.             'data' => [
  493.                 'script' => json_encode($templateContent)
  494.             ],
  495.         ];
  496.         return new JsonResponse($response);
  497.     }
  498.     /**
  499.      * Handle Karte when user click phone on any screen
  500.      *
  501.      * @Route("/Ajax/karte_download_fax_form", name="karte_download_fax_form", methods={"POST"})
  502.      */
  503.     public function ajaxKarteDownloadFaxFormRequest(Request $request)
  504.     {
  505.         $fromUrl $request->get('fromUrl''');
  506.         $lmCustomer null;
  507.         $customer $this->getUser();
  508.         if (!empty($customer)) {
  509.             $lmCustomer $this->customerService->GetLandMarkCustomerId($customer->getLmCustomerId());
  510.         }
  511.         $karte['download_fax_form'] = [
  512.             'from_url' => $fromUrl,
  513.             'email' => empty($lmCustomer) ? "" $lmCustomer['customer_mail'],
  514.             'ip_address' => $request->getClientIp(),
  515.         ];
  516.         $templateContent $this->renderView('Karte/download_fax_form.twig', [
  517.             'Karte' => $karte,
  518.         ]);
  519.         $response = [
  520.             'status' => 200,
  521.             'message' => 'Process completed successfully.',
  522.             'data' => [
  523.                 'script' => json_encode($templateContent)
  524.             ],
  525.         ];
  526.         return new JsonResponse($response);
  527.     }
  528.     /**
  529.      * Handle Karte when user access to route name page/sub-category
  530.      *
  531.      * @Route("/Ajax/karte_page_sub_category", name="karte_page_sub_category", methods={"POST"})
  532.      */
  533.     public function ajaxKartePageSubCategoryRequest(Request $request)
  534.     {
  535.         $listUrl $request->get('listUrl''');
  536.         $mcName $request->get('mcName'null);
  537.         $ct $request->get('ct'null);
  538.         $mcMcName $request->get('mcMcName'null);
  539.         $isMobile $request->get('isMobile'false) ? true false;
  540.         try {
  541.             // 親・子・祖父
  542.             $category = new CategoryWithRelated($mcName$ct$mcMcName$isMobile);
  543.         } catch (\Exception $e) {
  544.             // カテゴリデータの取得に失敗した場合「404 Not Found」とする
  545.             throw new NotFoundHttpException("指定されたカテゴリのデータが取得出来ませんでした({$e->getMessage()})"$e);
  546.         }
  547.         $karte['view_list'] = [
  548.             'list_url' => $listUrl,
  549.             'list_num' => $category->getItemListCount(),
  550.             'l_category_name' => $category->getMainCategoryName(),
  551.             's_category_name' => $category->getCategoryName(),
  552.             'l_category_cd' => $category->getMainCategoryWebname(),
  553.             's_category_cd' => $category->getCategoryWebname(),
  554.         ];
  555.         $templateContent $this->renderView('Karte/view_list.twig', [
  556.             'Karte' => $karte,
  557.         ]);
  558.         $response = [
  559.             'status' => 200,
  560.             'message' => 'Process completed successfully.',
  561.             'data' => [
  562.                 'script' => json_encode($templateContent)
  563.             ],
  564.         ];
  565.         return new JsonResponse($response);
  566.     }
  567. #本番では不要
  568. protected function Data(){
  569.    // $Data = $this->CartItemRepository->find(875);
  570.     //$Data = $this->CartItemRepository->find(556);
  571.     $Data $this->CartItemRepository->find(873);
  572.     return $Data->getOptions();
  573. }
  574. }