I have been struggling with this question for the past couple of hours and haven't been able to find anything.
I have configured the FOSUserBundle and have the groups activated correctly and working. However, the user-group relation is defined as follows in the User class :
/**
* @ORM\ManyToMany(targetEntity="Netlabs\UserBundle\Entity\Group")
* @ORM\JoinTable(name="fos_user_user_group",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
* )
*/
protected $groups;
and in the Group class, I do not even have a $user list defined. I tried loads of "normal" things like creating a $users variable in my Group class and defining it's relation to the User object, but it is not playing nice with the FOSUserBundle (every time, it creates a NEW table to create the relation, when there is already one in place). For example:
/**
* @ORM\ManyToMany(targetEntity="Netlabs\UserBundle\Entity\Group", inversedBy="groups", cascade={"all"})
*
*/
protected $users;
Any suggestions ?
Again, my main goal is : I want to be able to do Group->getUsers()