app/Plugin/SimulateLogin/Event.php line 43

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of SimulateLogin Plugin
  4.  *
  5.  * Copyright(c) https://beststore.tokyo/ All Rights Reserved.
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Plugin\SimulateLogin;
  11. use Plugin\SimulateLogin\Entity\HistoryGroup;
  12. use Plugin\SimulateLogin\Entity\History;
  13. use Plugin\SimulateLogin\Entity\ResultOrder;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. use Eccube\Event\TemplateEvent;
  16. use Plugin\SimulateLogin\Entity\Config;
  17. class Event implements EventSubscriberInterface
  18. {
  19.     private $twig;
  20.     
  21.     public function __construct(
  22.         \Twig\Environment $twig
  23.     )
  24.     {
  25.         $this->twig $twig;
  26.     }
  27.     /**
  28.      * @return array
  29.      */
  30.     public static function getSubscribedEvents()
  31.     {
  32.         return [
  33.             '@admin/Customer/index.twig' => 'onCustomerIndexTwig',
  34.         ];
  35.     }
  36.     public function onCustomerIndexTwig(TemplateEvent $event)
  37.     {
  38.         $source $event->getSource();
  39.         $pattern '|<div class="text-end">|s';
  40.         $append $this->twig->getLoader()->getSourceContext('@SimulateLogin/admin/Customer/index.twig')->getCode();
  41.         if (preg_match($pattern$source$matchesPREG_OFFSET_CAPTURE)) {
  42.             $replacement $matches[0][0] . $append;
  43.             $source preg_replace($pattern$replacement$source1);
  44.             $event->setSource($source);
  45.         }
  46.     }
  47. }