app/Plugin/CustomerRank42/Event/ShoppingEvent.php line 45

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\Event;
  12. use Eccube\Event\EccubeEvents;
  13. use Eccube\Event\EventArgs;
  14. use Plugin\CustomerRank42\Repository\CustomerRankRepository;
  15. use Plugin\CustomerRank42\Service\CustomerRankService;
  16. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  17. class ShoppingEvent implements EventSubscriberInterface
  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.      * @return array
  32.      */
  33.     public static function getSubscribedEvents()
  34.     {
  35.         return [
  36.             EccubeEvents::FRONT_SHOPPING_COMPLETE_INITIALIZE => 'hookFrontShoppingCompleteInitialize',
  37.         ];
  38.     }
  39.     public function hookFrontShoppingCompleteInitialize(EventArgs $event)
  40.     {
  41.         $Order $event->getArgument('Order');
  42.         $Customer $Order->getCustomer();
  43.         if(!is_null($Customer))$this->customerRankService->checkRank($Customer);
  44.     }
  45. }