0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ECCUBEプラグイン 4.2 → 4.3へ換装

Posted at

エラー

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
で上書き

エラー解消

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?