如何使用Symfony2中使用Doctrine2生成的Entites来指定Setter名称?
-
25-10-2019 - |
题
我有一个事件实体和一个具有单向性的用户实体,它们之间的关系很多。当我使用生成器(Doctrine:Generate:Entites)创建事件实体时,GetTeur称为GetParticipant和称为Adduser的Setter。
我想设置器是由目标实体的名称空间组成的。有一个选项谁允许在我的ORM设置中更改设置器名称?
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;
}
提前致谢。
解决方案
您不能影响生成的Getter和Setter方法的名称。但是,您可以随后更改它们,因为它们没有任何建筑目的。
不隶属于 StackOverflow