Ejemplo n.º 1
0
 /**
  * @param User $user
  * @throws \InvalidArgumentException
  * @internal param \App\Model\WishList $list
  * @return $this
  */
 public function removeFromUser(User $user)
 {
     if (!$user->loaded()) {
         throw new \InvalidArgumentException('User is not loaded.');
     }
     // If collection doesn't contain wish list, just stop
     if (!$user->wishlists->containsById($this)) {
         return $this;
     }
     // Else search for
     $itemInList = $user->wishlists->filterOneBy(array('id' => $this->id()));
     if ($itemInList) {
         $user->remove('wishlists', $itemInList);
     }
     return $this;
 }