app/Plugin/CustomerRank42/Controller/Block/CustomerRankInfoController.php line 40

Open in your IDE?
  1. <?php
  2. /*
  3. * Plugin Name : CustomerRank
  4. *
  5. * Copyright (C) BraTech Co., Ltd. All Rights Reserved.
  6. * http://www.bratech.co.jp/
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Plugin\CustomerRank42\Controller\Block;
  12. use Eccube\Controller\AbstractController;
  13. use Plugin\CustomerRank42\Service\CustomerRankService;
  14. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. class CustomerRankInfoController extends AbstractController
  18. {
  19.     private $customerRankService;
  20.     /**
  21.      * CustomerRankController constructor.
  22.      * @param CustomerRankRepository $customerRankRepository
  23.      */
  24.     public function __construct(
  25.             CustomerRankService $customerRankService
  26.             )
  27.     {
  28.         $this->customerRankService $customerRankService;
  29.     }
  30.     /**
  31.      * @Route("/block/customer_rank_info", name="block_customer_rank_info")
  32.      * @Template("Block/customer_rank_info.twig")
  33.      */
  34.     public function index(Request $request)
  35.     {
  36.         $Customer $this->customerRankService->getLoginCustomer();
  37.         if($Customer){
  38.             $checkCustomerRank $this->customerRankService->getCheckRank($Customertrue);
  39.             if($checkCustomerRank)$nextCustomerRank $this->customerRankService->getNextRank($checkCustomerRank);
  40.             $currentCondition $this->customerRankService->getCurrentCondition($Customertrue);
  41.             $currentCustomerRank $Customer->getCustomerRank();
  42.             if(!isset($nextCustomerRank) && $currentCustomerRank)$nextCustomerRank $this->customerRankService->getNextRank($currentCustomerRank);
  43.             if($currentCustomerRank){
  44.                 if($currentCustomerRank->getFixedFlg()){
  45.                     $checkCustomerRank = [];
  46.                     $nextCustomerRank = [];
  47.                 }
  48.             }
  49.             if($currentCustomerRank && $checkCustomerRank){
  50.                 if($currentCustomerRank->getId() == $checkCustomerRank->getId()){
  51.                     $checkCustomerRank = [];
  52.                 }
  53.             }
  54.         }
  55.         if(!isset($checkCustomerRank))$checkCustomerRank = [];
  56.         if(!isset($currentCustomerRank))$currentCustomerRank = [];
  57.         if(!isset($nextCustomerRank))$nextCustomerRank = [];
  58.         if(!isset($currentCondition))$currentCondition = [];
  59.         return [
  60.                     'CurrentCustomerRank' => $currentCustomerRank,
  61.                     'NextCustomerRank' => $nextCustomerRank,
  62.                     'CheckCustomerRank' => $checkCustomerRank,
  63.                     'CurrentCondition' => $currentCondition,
  64.         ];
  65.     }
  66. }