<?php
/*
* This file is part of CustomerGroupPrice
*
* 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\ParameterBag\ContainerBagInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class Event implements EventSubscriberInterface
{
/**
* @var ContainerBagInterface
*/
private ContainerBagInterface $container;
public function __construct(ContainerBagInterface $container)
{
$this->container = $container;
}
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
'@admin/Product/product.twig' => 'onTemplateAdminProduct',
'@CustomerGroup42/admin/Customer/Group/edit.twig' => 'onTemplateAdminCustomerGroupEdit',
'@CustomerGroup42/admin/config.twig' => 'onTemplateAdminCustomerGroupConfig',
];
}
/**
* @param TemplateEvent $event
*
* @return void
*/
public function onTemplateAdminProduct(TemplateEvent $event): void
{
$event->addSnippet('@CustomerGroupPrice42/admin/Product/product.twig');
}
/**
* @param TemplateEvent $event
*
* @return void
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function onTemplateAdminCustomerGroupEdit(TemplateEvent $event): void
{
$currency = $this->container->get('currency');
if ('JPY' === $currency) {
$event->addSnippet('@CustomerGroupPrice42/admin/Customer/Group/edit.twig');
}
}
/**
* @param TemplateEvent $event
*
* @return void
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function onTemplateAdminCustomerGroupConfig(TemplateEvent $event): void
{
$currency = $this->container->get('currency');
if ('JPY' === $currency) {
$event->addSnippet('@CustomerGroupPrice42/admin/config.twig');
}
}
}