app/Plugin/DesignTag42/Event.php line 65

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of DesignTag42
  4.  * Copyright(c) U-Mebius Inc. All Rights Reserved.
  5.  *
  6.  * https://umebius.com/
  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\DesignTag42;
  12. use Eccube\Common\Constant;
  13. use Eccube\Event\TemplateEvent;
  14. use Eccube\Repository\TagRepository;
  15. use Plugin\DesignTag42\Service\TwigService;
  16. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  17. class Event implements EventSubscriberInterface
  18. {
  19.     /**
  20.      * @var TwigService
  21.      */
  22.     private $twigService;
  23.     /**
  24.      * @var TagRepository
  25.      */
  26.     private $tagRepository;
  27.     public function __construct(
  28.         TwigService $twigService,
  29.         TagRepository $tagRepository
  30.     ) {
  31.         $this->tagRepository $tagRepository;
  32.         $this->twigService $twigService;
  33.     }
  34.     /**
  35.      * @return array
  36.      */
  37.     public static function getSubscribedEvents()
  38.     {
  39.         return [
  40.             '@admin/Product/tag.twig' => 'onAdminProductTagTwig',
  41.             'Product/detail.twig' => 'onProductDetailTwig',
  42.             'Product/list.twig' => 'onProductListTwig',
  43. /*▼RZ 2025.09.10 ADD デザインタグを購入フローにも反映▼*/
  44.             'Shopping/index.twig' => 'onShoppingTwig',
  45.             'Shopping/confirm.twig' => 'onShoppingConfirmTwig',
  46. /*▲RZ 2025.09.10 ADD デザインタグを購入フローにも反映▲*/
  47.         ];
  48.     }
  49.     public function onAdminProductTagTwig(TemplateEvent $event)
  50.     {
  51.         $event->addSnippet('@DesignTag42/admin/Product/tag.twig');
  52.         if (version_compare(Constant::VERSION'4.0.3') <= 0) {
  53.             $event->addSnippet('@DesignTag42/admin/Product/tag_lte_4_0_3.twig');
  54.         }
  55.     }
  56.     public function onProductDetailTwig(TemplateEvent $event)
  57.     {
  58.         $Product $event->getParameter('Product');
  59.         $DesignTags $Product->getTags();
  60.         $event->setParameter('DesignTags'$DesignTags);
  61.         $event->addAsset('@DesignTag42/tag_detail_css.twig');
  62.     }
  63.     public function onProductListTwig(TemplateEvent $event)
  64.     {
  65. //        $insert = $this->twigService->getTwigFile('@DesignTag42/tag_list.twig');
  66. //        $this->twigService->setSource($event->getSource());
  67. //        $this->twigService->insert('<p>{{ Product.name }}</p>', $insert);
  68. //        $event->setSource($this->twigService->getSource());
  69.         $DesignTags $this->tagRepository->findBy(['show_product_list_flg' => true]);
  70.         $event->setParameter('DesignTags'$DesignTags);
  71.         $event->addAsset('@DesignTag42/tag_list_css.twig');
  72.     }
  73. /*▼RZ 2025.09.10 ADD デザインタグを購入フローにも反映▼*/
  74.     public function onShoppingTwig(TemplateEvent $event)
  75.     {
  76.         $DesignTags $this->tagRepository->findAll();
  77.         $event->setParameter('DesignTags'$DesignTags);
  78.         $event->addAsset('@DesignTag42/tag_list_css.twig');
  79.     }
  80.     public function onShoppingConfirmTwig(TemplateEvent $event)
  81.     {
  82.         $DesignTags $this->tagRepository->findAll();
  83.         $event->setParameter('DesignTags'$DesignTags);
  84.         $event->addAsset('@DesignTag42/tag_list_css.twig');
  85.     }
  86. /*▲RZ 2025.09.10 ADD デザインタグを購入フローにも反映▲*/
  87. }