0
我有trait
它看起來像這樣主義特質覆蓋一對多關係
trait CommentableTrait
{
/**
* @OneToMany(targetEntity="Comment", mappeBy="to_override")
*
*/
protected $comments;
}
在Comment.php
我ManyToOne
關係
class Comment
{
/**
* @ManyToOne(targetEntity="Article", inversedBy="comments")
*/
protected $article;
/**
* @ManyToOne(targetEntity="Page", inversedBy="comments")
*/
protected $page;
/**
* @ManyToOne(targetEntity="Page", inversedBy="comments")
*/
protected $question;
}
我想在我的實體使用這個特質Article.php
,Page.php
,Quesion.php
像這樣:
class Article
{
use CommentableTrait;
}
我需要覆蓋CommenatableTrait
中的mappedBy
。
我試着從Doctrine - Override Field Association Mappings In Subclasses
解決它與OneToOne
和ManyToMany
關係,但我無法找到雙向OneToMany - ManyToOne
關係工作的例子。有沒有辦法做到這一點?