app/Plugin/CustomerGroupPrice42/Event.php line 46

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of CustomerGroupPrice42
  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\ContainerInterface;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. class Event implements EventSubscriberInterface
  17. {
  18.     /**
  19.      * @var ContainerInterface
  20.      */
  21.     private $container;
  22.     public function __construct(ContainerInterface $container)
  23.     {
  24.         $this->container $container;
  25.     }
  26.     public static function getSubscribedEvents(): array
  27.     {
  28.         return [
  29.             '@admin/Product/product.twig' => 'onTemplateAdminProduct',
  30.             '@CustomerGroup42/admin/Customer/Group/edit.twig' => 'onTemplateAdminCustomerGroupEdit',
  31.             '@CustomerGroup42/admin/config.twig' => 'onTemplateAdminCustomerGroupConfig',
  32.         ];
  33.     }
  34.     public function onTemplateAdminProduct(TemplateEvent $event): void
  35.     {
  36.         $event->addSnippet('@CustomerGroupPrice42/admin/Product/product.twig');
  37.     }
  38.     public function onTemplateAdminCustomerGroupEdit(TemplateEvent $event): void
  39.     {
  40.         $currency $this->container->getParameter('currency');
  41.         if ('JPY' === $currency) {
  42.             $event->addSnippet('@CustomerGroupPrice42/admin/Customer/Group/edit.twig');
  43.         }
  44.     }
  45.     public function onTemplateAdminCustomerGroupConfig(TemplateEvent $event): void
  46.     {
  47.         $currency $this->container->getParameter('currency');
  48.         if ('JPY' === $currency) {
  49.             $event->addSnippet('@CustomerGroupPrice42/admin/config.twig');
  50.         }
  51.     }
  52. }