开发者

How can I specify the setter name with the entites who's generated with Doctrine2 in Symfony2?

I have an event entity and a user entity with an unidirectionnal many to many relation between them. When, I created the event entity with the generator (doctrine:generate:entites) the getteur called getParticipants and the setter called AddUser.

I guess that the setter is composed by the namespace of the target entity. There is an option who allows to change the setter name in my orm settings?

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

Entity/Event.php

/**
 * Add participants
 *
 * @param RocketLab\UserBundle\Entity\User $participants
 */
public function addUser(\开发者_如何学PythonRocketLab\UserBundle\Entity\User $participants)
{
    $this->participants[] = $participants;
}

/**
 * Get participants
 *
 * @return Doctrine\Common\Collections\Collection 
 */
public function getParticipants()
{
    return $this->participants;
}

Thanks in advance.


You cannot influence the names of generated getter and setter methods. You can just change them afterwards though, as they serve no architectural purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜