【发布时间】:2014-03-11 23:09:31
【问题描述】:
当我在类中使用 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 dictionary:schema:update --force 我丢失了@ORM 注释中指定的“可为空”和“长度”选项。 如果我在 Class My 中定义相同的字段和相关注解,它会按预期工作。
【问题讨论】:
标签: php symfony orm doctrine-orm traits