/**
  * @param	User $user The user object to add.
  */
 protected function doAddUser(User $user)
 {
     // set the back reference to this object directly as using provided method either results
     // in endless loop or in multiple relations
     if (!$user->getGroups()->contains($this)) {
         $userGroup = new UserGroup();
         $userGroup->setUser($user);
         $this->addUserGroup($userGroup);
         $foreignCollection = $user->getGroups();
         $foreignCollection[] = $this;
     }
 }
Beispiel #2
0
 /**
  * Gets the groups granted to the user.
  *
  * @return Collection
  */
 public function getGroups()
 {
     return new GroupCollection($this->user->getGroups());
 }