app/Customize/Controller/Mypage/MypageController.php line 105

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.  */
  12. namespace Customize\Controller\Mypage;
  13. use Customize\Service\QrCodeService;
  14. use Eccube\Controller\AbstractController;
  15. use Eccube\Controller\Mypage\MypageController as MypageMypageController;
  16. use Eccube\Entity\BaseInfo;
  17. use Eccube\Entity\Customer;
  18. use Eccube\Entity\Order;
  19. use Eccube\Entity\Product;
  20. use Eccube\Event\EccubeEvents;
  21. use Eccube\Event\EventArgs;
  22. use Eccube\Exception\CartException;
  23. use Eccube\Form\Type\Front\CustomerLoginType;
  24. use Eccube\Repository\BaseInfoRepository;
  25. use Eccube\Repository\CustomerFavoriteProductRepository;
  26. use Eccube\Repository\OrderRepository;
  27. use Eccube\Repository\ProductRepository;
  28. use Eccube\Service\CartService;
  29. use Eccube\Service\PurchaseFlow\PurchaseContext;
  30. use Eccube\Service\PurchaseFlow\PurchaseFlow;
  31. use Knp\Component\Pager\PaginatorInterface;
  32. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  33. use Symfony\Component\HttpFoundation\Request;
  34. use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
  35. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  36. use Symfony\Component\Routing\Annotation\Route;
  37. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  38. class MypageController extends MypageMypageController
  39. {
  40.     /** @var QrCodeService */
  41.     private $qrCodeService;
  42.     /**
  43.      * MypageController constructor.
  44.      *
  45.      * @param OrderRepository $orderRepository
  46.      * @param CustomerFavoriteProductRepository $customerFavoriteProductRepository
  47.      * @param CartService $cartService
  48.      * @param BaseInfoRepository $baseInfoRepository
  49.      * @param PurchaseFlow $purchaseFlow
  50.      * @param QrCodeService $qrCodeService
  51.      */
  52.     public function __construct(
  53.         OrderRepository $orderRepository,
  54.         CustomerFavoriteProductRepository $customerFavoriteProductRepository,
  55.         CartService $cartService,
  56.         BaseInfoRepository $baseInfoRepository,
  57.         PurchaseFlow $purchaseFlow,
  58.         QrCodeService $qrCodeService,
  59.     ) {
  60.         parent::__construct($orderRepository,$customerFavoriteProductRepository,$cartService,$baseInfoRepository,$purchaseFlow);
  61.         $this->qrCodeService $qrCodeService;
  62.     }
  63.     /**
  64.      * ログイン画面.
  65.      *
  66.      * @Route("/mypage/login", name="mypage_login", methods={"GET", "POST"})
  67.      * @Template("Mypage/login.twig")
  68.      */
  69.     public function login(Request $requestAuthenticationUtils $utils)
  70.     {
  71.         if ($this->isGranted('IS_AUTHENTICATED_FULLY')) {
  72.             log_info('認証済のためログイン処理をスキップ');
  73.             return $this->redirectToRoute('mypage');
  74.         }
  75.         /* @var $form \Symfony\Component\Form\FormInterface */
  76.         $builder $this->formFactory
  77.             ->createNamedBuilder(''CustomerLoginType::class);
  78.         $builder->get('login_memory')->setData((bool) $request->getSession()->get('_security.login_memory'));
  79.         if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
  80.             $Customer $this->getUser();
  81.             if ($Customer instanceof Customer) {
  82.                 $builder->get('login_email')
  83.                     ->setData($Customer->getEmail());
  84.             }
  85.         }
  86.         $event = new EventArgs(
  87.             [
  88.                 'builder' => $builder,
  89.             ],
  90.             $request
  91.         );
  92.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_MYPAGE_MYPAGE_LOGIN_INITIALIZE);
  93.         $form $builder->getForm();
  94.         return [
  95.             'error' => $utils->getLastAuthenticationError(),
  96.             'form' => $form->createView(),
  97.         ];
  98.     }
  99.     /**
  100.      * マイページ.
  101.      *
  102.      * @Route("/mypage/", name="mypage", methods={"GET"})
  103.      * @Template("Mypage/index.twig")
  104.      */
  105.     public function index(Request $requestPaginatorInterface $paginator)
  106.     {
  107.         $Customer $this->getUser();
  108.         // 購入処理中/決済処理中ステータスの受注を非表示にする.
  109.         $this->entityManager
  110.             ->getFilters()
  111.             ->enable('incomplete_order_status_hidden');
  112.         // paginator
  113.         $qb $this->orderRepository->getQueryBuilderByCustomer($Customer);
  114.         $event = new EventArgs(
  115.             [
  116.                 'qb' => $qb,
  117.                 'Customer' => $Customer,
  118.             ],
  119.             $request
  120.         );
  121.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_MYPAGE_MYPAGE_INDEX_SEARCH);
  122.         $pagination $paginator->paginate(
  123.             $qb,
  124.             $request->get('pageno'1),
  125.             $this->eccubeConfig['eccube_search_pmax']
  126.         );
  127.         $qr_code $this->qrCodeService->generateQrCode($Customer);
  128.         return [
  129.             'pagination' => $pagination,
  130.             'qr_code'       => $qr_code,
  131.         ];
  132.     }
  133.     /**
  134.     * @Route("/mypage/qr_code", name="mypage_qr_code", methods={"GET"})
  135.     */
  136.     public function qrcode(Request $request){
  137.         $Customer $this->getUser();
  138.         $qr_code $this->qrCodeService->generateQrCode($Customer);
  139.         return $this->render('Mypage/qr_code.twig',[
  140.             'qr_code'   => $qr_code,
  141.         ]);
  142.     }
  143. }