<?php
namespace Plugin\MyufullConnect\EventListener\admin;
use Eccube\Event\TemplateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AdminEventSubscriber implements EventSubscriberInterface
{
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return [
'@admin/Customer/edit.twig' => ['onAdminCustomerEdit', -10],
'@admin/Order/edit.twig' => ['onAdminOrderEdit', -10],
];
}
/**
* MYUSEシステムと最新版か確認し、ECCが古いのであれば処理をかます
* @param TemplateEvent $event
*/
public function onAdminCustomerEdit(TemplateEvent $event)
{
$Customer = $event->getParameter('Customer');
if(true) {
$this->addAssets($event);
}
}
/**
* MYUSEシステムと最新版か確認し、ECCが古いのであれば処理をかます
* @param TemplateEvent $event
*/
public function onAdminOrderEdit(TemplateEvent $event)
{
$Order = $event->getParameter('Order');
if(true) {
$this->addAssets($event);
}
}
/**
* Formを送信不可にする
* 「更新」ボタンを表示
* @param TemplateEvent $event
*/
private function addAssets(TemplateEvent $event) {
$event->addAsset('MyufullConnect/Resource/assets/js/admin/disable_form.js');
$event->addSnippet('@MyufullConnect/admin/btn_myuse_update.twig');
}
}