示例#1
0
 /**
  * Remove user of this object
  * through the user_group cross reference table.
  *
  * @param ChildUser $user
  * @return ChildGroup The current object (for fluent API support)
  */
 public function removeUser(ChildUser $user)
 {
     if ($this->getUsers()->contains($user)) {
         $userGroup = new ChildUserGroup();
         $userGroup->setUser($user);
         if ($user->isGroupsLoaded()) {
             //remove the back reference if available
             $user->getGroups()->removeObject($this);
         }
         $userGroup->setGroup($this);
         $this->removeUserGroup(clone $userGroup);
         $userGroup->clear();
         $this->collUsers->remove($this->collUsers->search($user));
         if (null === $this->usersScheduledForDeletion) {
             $this->usersScheduledForDeletion = clone $this->collUsers;
             $this->usersScheduledForDeletion->clear();
         }
         $this->usersScheduledForDeletion->push($user);
     }
     return $this;
 }