Exemplo n.º 1
0
 /**
  * @param  ChildUser $user The ChildUser object to remove.
  * @return $this|ChildFile The current object (for fluent API support)
  */
 public function removeUser(ChildUser $user)
 {
     if ($this->getUsers()->contains($user)) {
         $pos = $this->collUsers->search($user);
         $this->collUsers->remove($pos);
         if (null === $this->usersScheduledForDeletion) {
             $this->usersScheduledForDeletion = clone $this->collUsers;
             $this->usersScheduledForDeletion->clear();
         }
         $this->usersScheduledForDeletion[] = $user;
         $user->setFile(null);
     }
     return $this;
 }
Exemplo n.º 2
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;
 }