app/Plugin/QuantityDiscountDx/EventSubscriber/AdminProductClassEventSubscriber.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright(c) 2019 SYSTEM_KD
  4.  * Date: 2019/03/16
  5.  */
  6. namespace Plugin\QuantityDiscountDx\EventSubscriber;
  7. use Eccube\Event\TemplateEvent;
  8. use Plugin\QuantityDiscountDx\Service\TwigRenderService\builder\EachChildContentBlockBuilder;
  9. use Plugin\QuantityDiscountDx\Service\TwigRenderService\TwigRenderService;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class AdminProductClassEventSubscriber implements EventSubscriberInterface
  12. {
  13.     /** @var TwigRenderService */
  14.     protected $twigRenderService;
  15.     public function __construct(
  16.         TwigRenderService $twigRenderService
  17.     )
  18.     {
  19.         $this->twigRenderService $twigRenderService;
  20.     }
  21.     /**
  22.      * 規格画面 テンプレート
  23.      *
  24.      * @param TemplateEvent $event
  25.      */
  26.     public function onTemplateProductProductClass(TemplateEvent $event)
  27.     {
  28.         $this->twigRenderService->initRenderService($event);
  29.         $insertPositionCol 7;
  30.         $this->twigRenderService
  31.             ->insertBuilder()
  32.             ->find('#ex-product_class')
  33.             ->find('th')->eq($insertPositionCol)
  34.             ->setTargetId('plugin_qd_area_title')
  35.             ->setInsertModeAfter();
  36.         // リスト
  37.         $eachChild $this->twigRenderService->eachChildBuilder();
  38.         $eachChild
  39.             ->findAndDataKey('#ex-product_class-''product_class_name')
  40.             ->find('td')
  41.             ->eq($insertPositionCol)
  42.             ->targetFindThis()
  43.             ->targetFind('td')
  44.             ->setInsertModeAfter();
  45.         $this->twigRenderService
  46.             ->eachBuilder()
  47.             ->find('.product_class_qd_area_target')
  48.             ->each($eachChild->build());
  49.         $this->twigRenderService->addSupportSnippet(
  50.             '@QuantityDiscountDx/admin/Product/product_class_qd_area.twig',
  51.             '@QuantityDiscountDx/admin/Product/product_class_qd_area_js.twig'
  52.         );
  53.     }
  54.     /**
  55.      * Returns an array of event names this subscriber wants to listen to.
  56.      *
  57.      * The array keys are event names and the value can be:
  58.      *
  59.      *  * The method name to call (priority defaults to 0)
  60.      *  * An array composed of the method name to call and the priority
  61.      *  * An array of arrays composed of the method names to call and respective
  62.      *    priorities, or 0 if unset
  63.      *
  64.      * For instance:
  65.      *
  66.      *  * ['eventName' => 'methodName']
  67.      *  * ['eventName' => ['methodName', $priority]]
  68.      *  * ['eventName' => [['methodName1', $priority], ['methodName2']]]
  69.      *
  70.      * @return array The event names to listen to
  71.      */
  72.     public static function getSubscribedEvents()
  73.     {
  74.         return [
  75.             '@admin/Product/product_class.twig' => ['onTemplateProductProductClass']
  76.         ];
  77.     }
  78. }