Example #1
0
 /**
  * Remove group of this object
  * through the user_group cross reference table.
  *
  * @param ChildGroup $group
  * @return ChildUser The current object (for fluent API support)
  */
 public function removeGroup(ChildGroup $group)
 {
     if ($this->getGroups()->contains($group)) {
         $userGroup = new ChildUserGroup();
         $userGroup->setGroup($group);
         if ($group->isUsersLoaded()) {
             //remove the back reference if available
             $group->getUsers()->removeObject($this);
         }
         $userGroup->setUser($this);
         $this->removeUserGroup(clone $userGroup);
         $userGroup->clear();
         $this->collGroups->remove($this->collGroups->search($group));
         if (null === $this->groupsScheduledForDeletion) {
             $this->groupsScheduledForDeletion = clone $this->collGroups;
             $this->groupsScheduledForDeletion->clear();
         }
         $this->groupsScheduledForDeletion->push($group);
     }
     return $this;
 }
Example #2
0
 /**
  * @param  ChildGroup $group The ChildGroup object to remove.
  * @return $this|ChildSport The current object (for fluent API support)
  */
 public function removeGroup(ChildGroup $group)
 {
     if ($this->getGroups()->contains($group)) {
         $pos = $this->collGroups->search($group);
         $this->collGroups->remove($pos);
         if (null === $this->groupsScheduledForDeletion) {
             $this->groupsScheduledForDeletion = clone $this->collGroups;
             $this->groupsScheduledForDeletion->clear();
         }
         $this->groupsScheduledForDeletion[] = clone $group;
         $group->setSport(null);
     }
     return $this;
 }