我正在学习教程:“如何定制可翻译的模型?”在Sylius文档中。
当我运行命令: php bin/console doctrine:migrations:diff时,我得到了这个错误:
致命错误: AppBundle\Entity\ShippingMethod::createTranslation():Sylius\Component\Shipping\Model\ShippingMethodTranslation的声明必须与第8行C:\wamp64\www\acme7\src\AppBundle\Entity\ShippingMethod.php中的Sylius\Component\Shipping\Model\ShippingMethod::createTranslation():Sylius\Component\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();
}
}有没有办法解决这个问题?
发布于 2017-11-23 00:31:17
我从sylius的松弛中得到了一些帮助。
因为我使用的是Sylius v1.0.4
我不得不替换:
use Sylius\Component\Shipping\Model\ShippingMethodTranslation;通过
use Sylius\Component\Shipping\Model\ShippingMethodTranslationInterface;和
/**
* {@inheritdoc}
*/
protected function createTranslation(): ShippingMethodTranslation
{
return new ShippingMethodTranslation();
}通过
/**
* {@inheritdoc}
*/
protected function createTranslation(): ShippingMethodTranslationInterface {
return new ShippingMethodTranslation();
}https://stackoverflow.com/questions/47432505
复制相似问题