遵循 Sylius 自定义工厂指南示例时出错

Error following Sylius Customizing Factories guide examples

我只是按照自定义指南进行操作,但在使用 ProductFactoryInterface 的自定义示例时遇到问题 (http://docs.sylius.org/en/1.0/customization/factory.html)

我总是得到同样的错误:

Compile Error: Declaration of AppBundle\Factory\ProductFactory::createWithVariant(): Sylius\Component\Core\Model\ProductInterface must be compatible with Sylius\Component\Product\Factory\ProductFactoryInterface::createWithVariant(): Sylius\Component\Product\Model\ProductInterface

我做错了什么?这是我的代码:

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 发布之前已经更改,似乎并非所有文档都相应地反映了这些更改。