【发布时间】:2017-11-22 10:37:20
【问题描述】:
我正在学习教程:“如何自定义可翻译模型?”在 Sylius 文档中。
当我运行命令时:php bin/console dictionary:migrations:diff 我得到了这个错误:
致命错误:AppBundle\Entity\ShippingMethod::createTranslation() 声明:Sylius\Component\Shipping\Model\ShippingMethodTranslation 必须与 Sylius\Component\Shipping\Model\ShippingMethod::createTranslation() 兼容:Sylius\Component第 8 行 C:\wamp64\www\acme7\src\AppBundle\Entity\ShippingMethod.php 中的 \Shipping\Model\ShippingMethodTranslationInterface
这是我的课:
<?php
namespace AppBundle\Entity;
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
use Sylius\Component\Shipping\Model\ShippingMethodTranslation;
class ShippingMethod extends BaseShippingMethod
{
/**
* @var string
*/
private $estimatedDeliveryTime;
/**
* @return string
*/
public function getEstimatedDeliveryTime(): string
{
return $this->estimatedDeliveryTime;
}
/**
* @param string $estimatedDeliveryTime
*/
public function setEstimatedDeliveryTime(string $estimatedDeliveryTime): void
{
$this->estimatedDeliveryTime = $estimatedDeliveryTime;
}
/**
* {@inheritdoc}
*/
protected function createTranslation(): ShippingMethodTranslation
{
return new ShippingMethodTranslation();
}
}
关于如何解决这个问题的任何想法?
【问题讨论】: