/** * @param ChildUserGroup $userGroup The ChildUserGroup object to remove. * @return $this|ChildGroup The current object (for fluent API support) */ public function removeUserGroup(ChildUserGroup $userGroup) { if ($this->getUserGroups()->contains($userGroup)) { $pos = $this->collUserGroups->search($userGroup); $this->collUserGroups->remove($pos); if (null === $this->userGroupsScheduledForDeletion) { $this->userGroupsScheduledForDeletion = clone $this->collUserGroups; $this->userGroupsScheduledForDeletion->clear(); } $this->userGroupsScheduledForDeletion[] = clone $userGroup; $userGroup->setGroup(null); } return $this; }