app/Plugin/RelatedProductPro/RelatedProductProEvent.php line 49

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.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 Plugin\RelatedProductPro;
  13. use Eccube\Event\TemplateEvent;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. use Plugin\RelatedProductPro\Repository\ConfigRepository;
  16. class RelatedProductProEvent implements EventSubscriberInterface
  17. {
  18.     protected $configRepository;
  19.     /**
  20.      * ConfigController constructor.
  21.      *
  22.      * @param ConfigRepository $configRepository
  23.      */
  24.     public function __construct(
  25.         ConfigRepository $configRepository
  26.     ){
  27.         $this->configRepository $configRepository;
  28.     }
  29.     public static function getSubscribedEvents()
  30.     {
  31.         return [
  32.             '@admin/Product/product.twig' => 'onRenderAdminProduct',
  33.             'Product/detail.twig' => 'onRenderProductDetail',
  34.         ];
  35.     }
  36.     /**
  37.      * フロント:商品詳細画面に関連商品を表示する.
  38.      *
  39.      * @param TemplateEvent $event
  40.      */
  41.     public function onRenderProductDetail(TemplateEvent $event)
  42.     {
  43.         $event->addSnippet('@RelatedProductPro/front/related_product.twig');
  44.         $relatedProductProConfig $this->configRepository->get();
  45.         $event->setParameter('relatedProductProConfig'$relatedProductProConfig);
  46.     }
  47.     /**
  48.      * 管理画面:商品登録画面に関連商品登録フォームを表示する.
  49.      *
  50.      * @param TemplateEvent $event
  51.      */
  52.     public function onRenderAdminProduct(TemplateEvent $event)
  53.     {
  54.         $event->addSnippet('@RelatedProductPro/admin/related_product.twig');
  55.         $relatedProductProConfig $this->configRepository->get();
  56.         $event->setParameter('relatedProductProConfig'$relatedProductProConfig);
  57.     }
  58. }