簡體   English   中英

遵循Sylius定制工廠指南示例時出錯

[英]Error following Sylius Customizing Factories guide examples

我只是在遵循自定義指南,並且在ProductFactoryInterface( http://docs.sylius.org/en/1.0/customization/factory.html )的自定義示例中遇到了問題

我總是得到相同的錯誤:

編譯錯誤:AppBundle \\ Factory \\ ProductFactory :: createWithVariant()的聲明:Sylius \\ Component \\ Core \\ Model \\ ProductInterface必須與Sylius \\ Component \\ Product \\ Factory \\ ProductFactoryInterface :: createWithVariant():Sylius \\ Component \\ Product \\型號\\產品接口

我究竟做錯了什么? 這是我的代碼:

namespace AppBundle\Factory;

use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Product\Factory\ProductFactoryInterface;

class ProductFactory implements ProductFactoryInterface
{
    /**
     * @var ProductFactoryInterface
     */
    private $decoratedFactory;

    /**
     * @param ProductFactoryInterface $factory
     */
    public function __construct(ProductFactoryInterface $factory)
    {
        $this->decoratedFactory = $factory;
    }

    /**
     * {@inheritdoc}
     */
    public function createNew(): ProductInterface
    {
        return $this->decoratedFactory->createNew();
    }

    /**
     * {@inheritdoc}
     */
    public function createWithVariant(): ProductInterface
    {
        return $this->decoratedFactory->createWithVariant();
    }

    /**
     * @return ProductInterface
     */
    public function createDisabled(): ProductInterface
    {
        /** @var ProductInterface $product */
        $product = $this->decoratedFactory->createNew();

        $product->setEnabled(false);

        return $product;
    }
}

如果您首先更改此use語句:

use Sylius\Component\Core\Model\ProductInterface;

帶有:

use Sylius\Component\Product\Model\ProductInterface;

在1.0.0版本之前,某些接口已更改,似乎並非所有文檔都相應地反映了此更改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM