当我在类中使用Trait时,会添加字段和方法,但部分ORM注释会丢失。
实施例
文件:CommonFields.php
Trait Commonfields
{
/**
* @ORM\Column(name="test", type="string", length=255, nullable=true)
*/
private test;
public function getTest()
{
return $this->test;
}
public function setTest($test)
{
$this->test = $test;
}
}
文件:My.php
class My
{
use CommonFields;
// ...the rest of My class
}
当我将实体与数据库同步时: php app / console doctrine:schema:update --force 我失去了@ORM Annotation中指定的“可空”和“长度”选项。 如果我在Class My中定义相同的字段和相关的注释,它将按预期工作。
答案 0 :(得分:1)
我知道这已经过时了,但我遇到了同样的问题,我通过清除缓存修复了它,然后php app/console doctrine:schema:update --force
希望有人觉得这很有用。
答案 1 :(得分:0)