<?php
/*
* Plugin Name : ExpressLink42
*
* Copyright (C) BraTech Co., Ltd. All Rights Reserved.
* http://www.bratech.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\ExpressLink42\Event;
use Eccube\Event\EventArgs;
use Eccube\Event\TemplateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ExpressLinkEvent implements EventSubscriberInterface
{
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Mypage/history.twig' => 'onTemplateFrontMypageHistory',
'csvimportproductext.admin.product.csv.import.product.process' => 'hookAdminProductCsvImportProductProcess',
];
}
public function onTemplateFrontMypageHistory(TemplateEvent $event)
{
$source = $event->getSource();
if(preg_match("/\{\{\sShipping\.shipping\_delivery\_name\s\}\}\<\/dd\>[\n|\r\n|\r]\s*\<\/div\>/",$source, $result)){
$search = $result[0];
$replace = $search . "{{ include('@ExpressLink42/default/Mypage/tracking_info.twig') }}";
$source = str_replace($search, $replace, $source);
}
$event->setSource($source);
}
public function hookAdminProductCsvImportProductProcess(EventArgs $event)
{
$row = $event->getArgument('row');
$ProductClass = $event->getArgument('ProductClass');
$Product = $ProductClass->getProduct();
if(isset($row[trans('expresslink.admin.form.product.label.shipping_name')])){
$Product->setShippingName($row[trans('expresslink.admin.form.product.label.shipping_name')]);
}
}
}