app/Plugin/PointEx/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\PointEx\EventSubscriber;
  7. use Eccube\Event\TemplateEvent;
  8. use Plugin\PointEx\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_bonus_title_''shippingIndex')
  31.             ->setInsertModeAfter();
  32.         $this->twigRenderService
  33.             ->eachBuilder()
  34.             ->find('[id^=table-form-field_]')
  35.             ->setEachIndexKey('shippingIndex')
  36.             ->each($childTitle->build());
  37.         // ボーナスポイント
  38.         $childItem $this->twigRenderService
  39.             ->eachChildBuilder()
  40.             ->findThis()
  41.             ->find('td')->eq($insertPosition)
  42.             ->targetFindAndIndexKey('#point_ex_bonus_[dateKey]_''pointExIndex')
  43.             ->setInsertModeAfter();
  44.         $childShopping $this->twigRenderService
  45.             ->eachChildBuilder()
  46.             ->findAndDataKey('#table-form-field_''shipping_index')
  47.             ->find('tbody > tr')
  48.             ->setEachIndexKey('pointExIndex')
  49.             ->each($childItem->build());
  50.         $this->twigRenderService
  51.             ->eachBuilder()
  52.             ->find('.point_ex_bonus')
  53.             ->each($childShopping->build());
  54.         $this->twigRenderService->addSupportSnippet(
  55.             '@PointEx/admin/Order/point_ex_order_shipping.twig',
  56.             nulltrue
  57.         );
  58.     }
  59.     /**
  60.      * Returns an array of event names this subscriber wants to listen to.
  61.      *
  62.      * The array keys are event names and the value can be:
  63.      *
  64.      *  * The method name to call (priority defaults to 0)
  65.      *  * An array composed of the method name to call and the priority
  66.      *  * An array of arrays composed of the method names to call and respective
  67.      *    priorities, or 0 if unset
  68.      *
  69.      * For instance:
  70.      *
  71.      *  * ['eventName' => 'methodName']
  72.      *  * ['eventName' => ['methodName', $priority]]
  73.      *  * ['eventName' => [['methodName1', $priority], ['methodName2']]]
  74.      *
  75.      * @return array The event names to listen to
  76.      */
  77.     public static function getSubscribedEvents()
  78.     {
  79.         return [
  80.             '@admin/Order/shipping.twig' => ['onTemplateAdminOrderShipping']
  81.         ];
  82.     }
  83. }