app/Plugin/TeikiOrder42/EventSubscriber/Controller/ProductControllerSubscriber.php line 78

Open in your IDE?
  1. <?php
  2. namespace Plugin\TeikiOrder42\EventSubscriber\Controller;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Eccube\Common\EccubeConfig;
  6. use Eccube\Event\TemplateEvent;
  7. use Eccube\Event\EventArgs;
  8. use Eccube\Event\EccubeEvents;
  9. use Eccube\Entity\Product;
  10. use Eccube\Service\CartService;
  11. use Eccube\Util\StringUtil;
  12. use Eccube\Repository\CartItemRepository;
  13. class ProductControllerSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var EntityManagerInterface
  17.      */
  18.     private $entityManager;
  19.     /**
  20.      * @var EccubeConfig
  21.      */
  22.     private $eccubeConfig;
  23.     /**
  24.      * @var CartService
  25.      */
  26.     private $cartService;
  27.     /**
  28.      * @var CartItemRepository
  29.      */
  30.     private $cartItemRepository;
  31.     /**
  32.      * Event constructor.
  33.      * @param EntityManagerInterface $entityManager
  34.      * @param EccubeConfig $eccubeConfig
  35.      * @param CartService $cartService
  36.      * @param CartItemRepository $cartItemRepository
  37.      */
  38.     public function __construct(
  39.         EntityManagerInterface $entityManager,
  40.         EccubeConfig $eccubeConfig,
  41.         CartService $cartService,
  42.         CartItemRepository $cartItemRepository
  43.     ) {
  44.         $this->entityManager $entityManager;
  45.         $this->eccubeConfig $eccubeConfig;
  46.         $this->cartService $cartService;
  47.         $this->cartItemRepository $cartItemRepository;
  48.     }
  49.     /**
  50.      * @return array
  51.      */
  52.     public static function getSubscribedEvents()
  53.     {
  54.         return [
  55.             'Product/list.twig' => ['DefaultProductList'1],
  56.             EccubeEvents::FRONT_PRODUCT_CART_ADD_INITIALIZE => 'FrontProductCartAddInitialize',
  57.         ];
  58.     }
  59.     /**
  60.      * @param TemplateEvent $event
  61.      */
  62.     public function DefaultProductList(TemplateEvent $event)
  63.     {
  64.         //$event->addSnippet('@AddOnForProductOption42/default/Product/product_list.twig');
  65.     }
  66.     public function FrontProductCartAddInitialize(EventArgs $event)
  67.     {
  68.         $Product $event->getArgument('Product');
  69.         $Cart $this->cartService->getCart();
  70.     }
  71. }