app/Plugin/ExpressLink42/Event/ExpressLinkEvent.php line 31

Open in your IDE?
  1. <?php
  2. /*
  3. * Plugin Name : ExpressLink42
  4. *
  5. * Copyright (C) BraTech Co., Ltd. All Rights Reserved.
  6. * http://www.bratech.co.jp/
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Plugin\ExpressLink42\Event;
  12. use Eccube\Event\EventArgs;
  13. use Eccube\Event\TemplateEvent;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. class ExpressLinkEvent implements EventSubscriberInterface
  16. {
  17.     /**
  18.      * @return array
  19.      */
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return [
  23.             'Mypage/history.twig' => 'onTemplateFrontMypageHistory',
  24.             'csvimportproductext.admin.product.csv.import.product.process' => 'hookAdminProductCsvImportProductProcess',
  25.         ];
  26.     }
  27.     public function onTemplateFrontMypageHistory(TemplateEvent $event)
  28.     {
  29.         $source $event->getSource();
  30.         if(preg_match("/\{\{\sShipping\.shipping\_delivery\_name\s\}\}\<\/dd\>[\n|\r\n|\r]\s*\<\/div\>/",$source$result)){
  31.             $search $result[0];
  32.             $replace $search "{{ include('@ExpressLink42/default/Mypage/tracking_info.twig') }}";
  33.             $source str_replace($search$replace$source);
  34.         }
  35.         $event->setSource($source);
  36.     }
  37.     public function hookAdminProductCsvImportProductProcess(EventArgs $event)
  38.     {
  39.         $row $event->getArgument('row');
  40.         $ProductClass $event->getArgument('ProductClass');
  41.         $Product $ProductClass->getProduct();
  42.         if(isset($row[trans('expresslink.admin.form.product.label.shipping_name')])){
  43.             $Product->setShippingName($row[trans('expresslink.admin.form.product.label.shipping_name')]);
  44.         }
  45.     }
  46. }