app/Plugin/CustomerGroupPrice42/Event.php line 78

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of CustomerGroupPrice
  4.  *
  5.  * Copyright(c) Akira Kurozumi <info@a-zumi.net>
  6.  *
  7.  * https://a-zumi.net
  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\CustomerGroupPrice42;
  13. use Eccube\Event\TemplateEvent;
  14. use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. class Event implements EventSubscriberInterface
  17. {
  18.     /**
  19.      * @var ContainerBagInterface
  20.      */
  21.     private ContainerBagInterface $container;
  22.     public function __construct(ContainerBagInterface $container)
  23.     {
  24.         $this->container $container;
  25.     }
  26.     /**
  27.      * @return string[]
  28.      */
  29.     public static function getSubscribedEvents(): array
  30.     {
  31.         return [
  32.             '@admin/Product/product.twig' => 'onTemplateAdminProduct',
  33.             '@CustomerGroup42/admin/Customer/Group/edit.twig' => 'onTemplateAdminCustomerGroupEdit',
  34.             '@CustomerGroup42/admin/config.twig' => 'onTemplateAdminCustomerGroupConfig',
  35.         ];
  36.     }
  37.     /**
  38.      * @param TemplateEvent $event
  39.      *
  40.      * @return void
  41.      */
  42.     public function onTemplateAdminProduct(TemplateEvent $event): void
  43.     {
  44.         $event->addSnippet('@CustomerGroupPrice42/admin/Product/product.twig');
  45.     }
  46.     /**
  47.      * @param TemplateEvent $event
  48.      *
  49.      * @return void
  50.      *
  51.      * @throws \Psr\Container\ContainerExceptionInterface
  52.      * @throws \Psr\Container\NotFoundExceptionInterface
  53.      */
  54.     public function onTemplateAdminCustomerGroupEdit(TemplateEvent $event): void
  55.     {
  56.         $currency $this->container->get('currency');
  57.         if ('JPY' === $currency) {
  58.             $event->addSnippet('@CustomerGroupPrice42/admin/Customer/Group/edit.twig');
  59.         }
  60.     }
  61.     /**
  62.      * @param TemplateEvent $event
  63.      *
  64.      * @return void
  65.      *
  66.      * @throws \Psr\Container\ContainerExceptionInterface
  67.      * @throws \Psr\Container\NotFoundExceptionInterface
  68.      */
  69.     public function onTemplateAdminCustomerGroupConfig(TemplateEvent $event): void
  70.     {
  71.         $currency $this->container->get('currency');
  72.         if ('JPY' === $currency) {
  73.             $event->addSnippet('@CustomerGroupPrice42/admin/config.twig');
  74.         }
  75.     }
  76. }