<?php
/*
* This file is part of SimulateLogin Plugin
*
* Copyright(c) https://beststore.tokyo/ All Rights Reserved.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\SimulateLogin;
use Plugin\SimulateLogin\Entity\HistoryGroup;
use Plugin\SimulateLogin\Entity\History;
use Plugin\SimulateLogin\Entity\ResultOrder;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Eccube\Event\TemplateEvent;
use Plugin\SimulateLogin\Entity\Config;
class Event implements EventSubscriberInterface
{
private $twig;
public function __construct(
\Twig\Environment $twig
)
{
$this->twig = $twig;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'@admin/Customer/index.twig' => 'onCustomerIndexTwig',
];
}
public function onCustomerIndexTwig(TemplateEvent $event)
{
$source = $event->getSource();
$pattern = '|<div class="text-end">|s';
$append = $this->twig->getLoader()->getSourceContext('@SimulateLogin/admin/Customer/index.twig')->getCode();
if (preg_match($pattern, $source, $matches, PREG_OFFSET_CAPTURE)) {
$replacement = $matches[0][0] . $append;
$source = preg_replace($pattern, $replacement, $source, 1);
$event->setSource($source);
}
}
}