3
我有一个事件实体和一个单向的多用户关系的用户实体。何时,我使用生成器(doctrine:generate:entites)创建了名为getParticipants的getteur和名为AddUser的setter。如何在Symfony2中使用Doctrine2生成的实体指定setter名称?
我猜测setter是由目标实体的命名空间组成的。 有一个选项允许在我的orm设置中更改setter名称?
Event.orm.yml
participants:
targetEntity: RocketLab\UserBundle\Entity\User
joinTable:
name: event_user
joinColumns:
user_id:
referencedColumnName: id
onDelete: CASCADE
inverseJoinColumns:
event_id:
onDelete: CASCADE
referencedColumnName: id
实体/ Event.php
/**
* Add participants
*
* @param RocketLab\UserBundle\Entity\User $participants
*/
public function addUser(\RocketLab\UserBundle\Entity\User $participants)
{
$this->participants[] = $participants;
}
/**
* Get participants
*
* @return Doctrine\Common\Collections\Collection
*/
public function getParticipants()
{
return $this->participants;
}
在此先感谢。
好的,但很遗憾我们无法改变它。 谢谢 – gperriard
我不太确定。我的意思迟早你不得不手动编码。通常选择的名字确实有意义。 – Raffael