<?php
/**
* This file is part of CustomerGroupPrice42
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\CustomerGroupPrice42;
use Eccube\Event\TemplateEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class Event implements EventSubscriberInterface
{
/**
* @var ContainerInterface
*/
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public static function getSubscribedEvents(): array
{
return [
'@admin/Product/product.twig' => 'onTemplateAdminProduct',
'@CustomerGroup42/admin/Customer/Group/edit.twig' => 'onTemplateAdminCustomerGroupEdit',
'@CustomerGroup42/admin/config.twig' => 'onTemplateAdminCustomerGroupConfig',
];
}
public function onTemplateAdminProduct(TemplateEvent $event): void
{
$event->addSnippet('@CustomerGroupPrice42/admin/Product/product.twig');
}
public function onTemplateAdminCustomerGroupEdit(TemplateEvent $event): void
{
$currency = $this->container->getParameter('currency');
if ('JPY' === $currency) {
$event->addSnippet('@CustomerGroupPrice42/admin/Customer/Group/edit.twig');
}
}
public function onTemplateAdminCustomerGroupConfig(TemplateEvent $event): void
{
$currency = $this->container->getParameter('currency');
if ('JPY' === $currency) {
$event->addSnippet('@CustomerGroupPrice42/admin/config.twig');
}
}
}