app/Customize/Controller/TopController.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  * 2024/05/10 Pico鈴木 サロンオーナーに会員登録用QRを出さないように修正
  12.  */
  13. namespace Customize\Controller;
  14. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. //追加
  17. use Eccube\Controller\AbstractController;
  18. use Customize\Repository\EigyoRepository;
  19. use Customize\Repository\QRCodeMikiRepository;
  20. use Customize\Repository\CustomerRepository;
  21. class TopController extends AbstractController
  22. {
  23.     /**
  24.      * @Route("/", name="homepage", methods={"GET"})
  25.      * @Template("index.twig")
  26.      */
  27.     public function index()
  28.     {
  29.         /* Cookieに会員情報をセット */
  30.         $this->setCookieSenyoPage();
  31.         return [];
  32.     }
  33. //専用ページにCookieで会員情報を渡すため以下追加
  34.     /**
  35.      * @var EigyoRepository
  36.      */
  37.     protected $eigyoRepository;
  38.     /**
  39.      * @var QRCodeMikiRepository
  40.      */
  41.     protected $qrcodeMikiRepository;
  42.     public function __construct(
  43.         EigyoRepository $eigyoRepository,
  44.         QRCodeMikiRepository $qrcodeMikiRepository
  45.     )
  46.     {
  47.         $this->eigyoRepository $eigyoRepository;
  48.         $this->qrcodeMikiRepository $qrcodeMikiRepository;
  49.     }
  50.     /**
  51.     * 専用ページ用Cookie設定処理
  52.     */
  53.     private function setCookieSenyoPage()
  54.     {
  55.         $Customer $this->getUser();
  56.         if ($Customer->getHostKono() != null) {
  57.             $bcKbn $Customer->getBc()->getId();
  58.             $sibuCd $Customer->getSibu()->getSibuCd();
  59.             $Eigyo $this->eigyoRepository->findOneBy(['sibu_cd' => $Customer->getSibu()->getSibuCd(), 'eigyo_cd' => $Customer->getEigyoCd()]);
  60.             $eigyoCd $Customer->getEigyoCd();
  61.             $hostKono $Customer->getHostKono();
  62.             $qrPath '';
  63.             $qrCCode '';
  64.             $qrMikiPCode '';
  65.             $qrMikiPath '';
  66.             $qrSOSCode '';
  67.             $qrSOPath '';
  68.             if ($bcKbn != 5) {
  69.                 //パートナー以外
  70.                 if ($bcKbn != 6) {
  71.                     //サロンオーナー以外
  72.                     $qrPath '/bsof/QRCode/' $Customer->getSibu()->getSibuCd() . $Customer->getEigyoCd() . '.gif';
  73.                     $qrCCode $Eigyo->getCampaignCd10();
  74.                 }
  75.                 $QRCodeMiki $this->qrcodeMikiRepository->findOneBy(['sibu_cd' => $Customer->getSibu()->getSibuCd(), 'eigyo_cd' => $Customer->getEigyoCd()]);
  76.                 if (!is_null($QRCodeMiki)) {
  77.                     $qrMikiPCode $QRCodeMiki->getPcode();
  78.                     $qrMikiPath '/bsof/QRCodeMiki/' $qrMikiPCode .'.gif';
  79.                 }
  80.                 //フォルダに該当ファイルがあるかチェック 例:/bsof/QRCodeSO/S3990009999_SSALONQRDUMY.gif
  81.                 $qrFolder $_SERVER["DOCUMENT_ROOT"] . "/bsof/QRCodeSO/";
  82.                 $handle opendir($qrFolder);
  83.                 if (false == is_null($handle)){
  84.                     while (false !== ($fileName readdir($handle))){
  85.                         if (is_file($qrFolder $fileName)){
  86.                             if (pathinfo($qrFolder $fileNamePATHINFO_EXTENSION) == "gif"){
  87.                                 if (substr($fileName011) == 'S' $sibuCd $eigyoCd "9999"){
  88.                                     // ファイル名が前方一致したので、ファイル名からSコードを切り出す
  89.                                     $qrSOPath "/bsof/QRCodeSO/" $fileName;
  90.                                     $qrSOSCode substr($fileName1212); 
  91.                                 }
  92.                             }
  93.                         }
  94.                     }
  95.                     closedir($handle);
  96.                 }
  97.             }
  98.             
  99.             //ライフタイム=0,クッキーパス=/でクッキーを作成
  100.             setcookie('ec'serialize(array('bc_kbn'=>$bcKbn
  101.              'sibu_cd'=>$sibuCd,
  102.               'eigyo_cd'=>$eigyoCd,
  103.                 'host_kono'=>$hostKono,
  104.                 'qr_path'=>$qrPath,
  105.                 'qr_ccode'=>$qrCCode,
  106.                 'qrmiki_path'=>$qrMikiPath,
  107.                 'qrmiki_pcode'=>$qrMikiPCode,
  108.                 'qrso_path'=>$qrSOPath,
  109.                 'qrso_scode'=>$qrSOSCode)), 0'/');
  110.                //WordPress側でUnSeiralizeできないためCSVで出力
  111.                setcookie('ec_wp''bc_kbn|' $bcKbn .
  112.              ',sibu_cd|' $sibuCd .
  113.               ',eigyo_cd|' $eigyoCd 
  114.                 ',host_kono|' $hostKono 
  115.                 ',qr_path|' $qrPath 
  116.                 ',qr_ccode|' $qrCCode 
  117.                 ',qrmiki_path|' $qrMikiPath 
  118.                 ',qrmiki_pcode|' $qrMikiPCode 
  119.                 ',qrso_path|' $qrSOPath 
  120.                 ',qrso_scode|' $qrSOSCode0'/');
  121.         }
  122.     }
  123. }