<?php/** * Copyright(c) 2019 SYSTEM_KD * Date: 2019/07/26 */namespace Plugin\PointExDx\EventSubscriber;use Eccube\Event\TemplateEvent;use Plugin\PointExDx\Config\ConfigSetting;use Plugin\PointExDx\Service\PlgConfigService\ConfigService;use Plugin\PointExDx\Service\PointExDxHelper;use Plugin\PointExDx\Service\TwigRenderService\TwigRenderService;use Symfony\Component\EventDispatcher\EventSubscriberInterface;class CartEventSubscriber implements EventSubscriberInterface{    /** @var TwigRenderService */    protected $twigRenderService;    /** @var ConfigService */    protected $configService;    /** @var PointExDxHelper */    protected $pointExHelper;    public function __construct(        TwigRenderService $twigRenderService,        ConfigService $configService,        PointExDxHelper $pointExHelper    )    {        $this->twigRenderService = $twigRenderService;        $this->configService = $configService;        $this->pointExHelper = $pointExHelper;    }    /**     * カートテンプレート     *     * @param TemplateEvent $event     */    public function onTemplateCartIndex(TemplateEvent $event)    {        if (!$this->pointExHelper->isPointUse()) {            // ポイント利用が無効の場合表示しない            return;        }        if ($this->configService->isKeyBool(ConfigSetting::KEY_CART_VIEW)) {            $this->twigRenderService->initRenderService($event);            $eachChild = $this->twigRenderService                ->eachChildBuilder()                ->findThis()                ->targetFindAndIndexKey('#point_ex_bonus_point_', 'pexIndex')                ->setInsertModeAppend();            $this->twigRenderService                ->eachBuilder()                ->find('.ec-cartRow')                ->find('.ec-cartRow__summary')                ->setEachIndexKey('pexIndex')                ->each($eachChild->build());            $this->twigRenderService->addSupportSnippet(                '@PointExDx/default/Cart/index_ex.twig'            );        }    }    /**     * Returns an array of event names this subscriber wants to listen to.     *     * The array keys are event names and the value can be:     *     *  * The method name to call (priority defaults to 0)     *  * An array composed of the method name to call and the priority     *  * An array of arrays composed of the method names to call and respective     *    priorities, or 0 if unset     *     * For instance:     *     *  * ['eventName' => 'methodName']     *  * ['eventName' => ['methodName', $priority]]     *  * ['eventName' => [['methodName1', $priority], ['methodName2']]]     *     * @return array The event names to listen to     */    public static function getSubscribedEvents()    {        return [            'Cart/index.twig' => ['onTemplateCartIndex', 10]        ];    }}