/** * Remove wine of this object * through the tasted_wine cross reference table. * * @param ChildWine $wine * @return ChildUser The current object (for fluent API support) */ public function removeWine(ChildWine $wine) { if ($this->getWines()->contains($wine)) { $tastedWine = new ChildTastedWine(); $tastedWine->setWine($wine); if ($wine->isUsersLoaded()) { //remove the back reference if available $wine->getUsers()->removeObject($this); } $tastedWine->setUser($this); $this->removeTastedWine(clone $tastedWine); $tastedWine->clear(); $this->collWines->remove($this->collWines->search($wine)); if (null === $this->winesScheduledForDeletion) { $this->winesScheduledForDeletion = clone $this->collWines; $this->winesScheduledForDeletion->clear(); } $this->winesScheduledForDeletion->push($wine); } return $this; }