エラー
An exception has been thrown during the rendering of a template ("Plugin\PluginName\Event::__construct(): Argument #1 ($twig) must be of type Twig_Environment, Twig\Environment given, called in /home/www/eccube-root/var/cache/dev/Container8nl8xnu/getEventService.php on line 29").
原因コード
root/app/Plugin/PluginName/Event.php
<?php
namespace Plugin\PluginName;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Eccube\Event\TemplateEvent;
/**
* ページをプラグイン用に差し替え
*/
class Event implements EventSubscriberInterface
{
public function __construct(\Twig_Environment $twig)
{
$this->twig = $twig;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Cart/index.twig' => ['onTemplateCartIndex', 999999]
];
}
public function onTemplateCartIndex(TemplateEvent $event)
{
$source = $this->twig->getLoader()
->getSourceContext("@PluginName/default/Cart/index.twig")
->getCode();
$event->setSource($source);
}
}
14行目
\Twig_Environment
を
\Twig\Environment
で上書き
エラー解消