-1

我正在开发基于 Symfony 框架的 Shopware 6 插件,但出现了以下错误。我该如何解决。

错误

函数 ReCachePlugin\Listener\ProductLoadedListener::__construct() 的参数太少,0 传入 /var/www/html/var/cache/dev_hc1f33717e842213f197359a55fd4cf51/ContainerZIOKqPk/Shopware_Production_KernelDevDebugContainer.php 在第 10676 行,恰好是 2

我的 Services.xml 文件

<services>
  <service id="ReCachePlugin\Listener\ProductLoadedListener" >
    <tag  name="kernel.event_listener" event="product.loaded" />
  </service>
</services>

我的代码

<?php declare(strict_types=1);

namespace ReCachePlugin\Listener;

use Shopware\Core\Framework\DataAbstractionLayer\Pricing\Price;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;


class ProductLoadedListener{
    
  /**
  * @var EntityLoadedEvent
  */
  private $entityLoadedEvent;

  /**
  * @var Price
  */
  private $price;

  public function __construct(EntityLoadedEvent $entityLoadedEvent, Price $price)
  {
    $this->Price = $price;
    $this->EntityLoadedEvent = $entityLoadedEvent;
  } 
    
  public function onProductLoaded()
  {
    print_r($this->EntityLoadedEvent->getIds());
  }

}

4

0 回答 0