app/Plugin/PointExDx/EventSubscriber/AdminShippingEventSubscriber.php line 27

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright(c) 2019 SYSTEM_KD
  4.  * Date: 2019/07/15
  5.  */
  6. namespace Plugin\PointExDx\EventSubscriber;
  7. use Eccube\Event\TemplateEvent;
  8. use Plugin\PointExDx\Service\TwigRenderService\TwigRenderService;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. class AdminShippingEventSubscriber implements EventSubscriberInterface
  11. {
  12.     /** @var TwigRenderService */
  13.     protected $twigRenderService;
  14.     public function __construct(
  15.         TwigRenderService $twigRenderService
  16.     )
  17.     {
  18.         $this->twigRenderService $twigRenderService;
  19.     }
  20.     public function onTemplateAdminOrderShipping(TemplateEvent $event)
  21.     {
  22.         $this->twigRenderService->initRenderService($event);
  23.         $insertPosition 5;
  24.         // ポイント付与対象
  25.         $childTitle $this->twigRenderService
  26.             ->eachChildBuilder()
  27.             ->findThis()
  28.             ->find('thead > tr > th')
  29.             ->eq($insertPosition)
  30.             ->targetFindAndIndexKey('#point_ex_nopointflg_title_''shippingIndex2')
  31.             ->setInsertModeAfter();
  32.         $this->twigRenderService
  33.             ->eachBuilder()
  34.             ->find('[id^=table-form-field_]')
  35.             ->setEachIndexKey('shippingIndex2')
  36.             ->each($childTitle->build());
  37.         // ボーナスポイント
  38.         $childTitle $this->twigRenderService
  39.             ->eachChildBuilder()
  40.             ->findThis()
  41.             ->find('thead > tr > th')
  42.             ->eq($insertPosition)
  43.             ->targetFindAndIndexKey('#point_ex_bonus_title_''shippingIndex')
  44.             ->setInsertModeAfter();
  45.         $this->twigRenderService
  46.             ->eachBuilder()
  47.             ->find('[id^=table-form-field_]')
  48.             ->setEachIndexKey('shippingIndex')
  49.             ->each($childTitle->build());
  50.         // ポイント付与対象
  51.         $childItem $this->twigRenderService
  52.             ->eachChildBuilder()
  53.             ->findThis()
  54.             ->find('td')->eq($insertPosition)
  55.             ->targetFindAndIndexKey('#point_ex_nopointflg_[dateKey]_''pointExIndex2')
  56.             ->setInsertModeAfter();
  57.         $childShopping $this->twigRenderService
  58.             ->eachChildBuilder()
  59.             ->findAndDataKey('#table-form-field_''shipping_index')
  60.             ->find('tbody > tr')
  61.             ->setEachIndexKey('pointExIndex2')
  62.             ->each($childItem->build());
  63.         $this->twigRenderService
  64.             ->eachBuilder()
  65.             ->find('.point_ex_nopointflg')
  66.             ->each($childShopping->build());
  67.         // ボーナスポイント
  68.         $childItem $this->twigRenderService
  69.             ->eachChildBuilder()
  70.             ->findThis()
  71.             ->find('td')->eq($insertPosition)
  72.             ->targetFindAndIndexKey('#point_ex_bonus_[dateKey]_''pointExIndex')
  73.             ->setInsertModeAfter();
  74.         $childShopping $this->twigRenderService
  75.             ->eachChildBuilder()
  76.             ->findAndDataKey('#table-form-field_''shipping_index')
  77.             ->find('tbody > tr')
  78.             ->setEachIndexKey('pointExIndex')
  79.             ->each($childItem->build());
  80.         $this->twigRenderService
  81.             ->eachBuilder()
  82.             ->find('.point_ex_bonus')
  83.             ->each($childShopping->build());
  84.         $this->twigRenderService->addSupportSnippet(
  85.             '@PointExDx/admin/Order/point_ex_order_shipping.twig',
  86.             nullfalse
  87.         );
  88.     }
  89.     /**
  90.      * Returns an array of event names this subscriber wants to listen to.
  91.      *
  92.      * The array keys are event names and the value can be:
  93.      *
  94.      *  * The method name to call (priority defaults to 0)
  95.      *  * An array composed of the method name to call and the priority
  96.      *  * An array of arrays composed of the method names to call and respective
  97.      *    priorities, or 0 if unset
  98.      *
  99.      * For instance:
  100.      *
  101.      *  * ['eventName' => 'methodName']
  102.      *  * ['eventName' => ['methodName', $priority]]
  103.      *  * ['eventName' => [['methodName1', $priority], ['methodName2']]]
  104.      *
  105.      * @return array The event names to listen to
  106.      */
  107.     public static function getSubscribedEvents()
  108.     {
  109.         return [
  110.             '@admin/Order/shipping.twig' => ['onTemplateAdminOrderShipping']
  111.         ];
  112.     }
  113. }