/** * Remove object of this object * through the object_category cross reference table. * * @param ChildObject $object * @return ChildCategory The current object (for fluent API support) */ public function removeObject(ChildObject $object) { if ($this->getObjects()->contains($object)) { $objectCategory = new ChildObjectCategory(); $objectCategory->setObject($object); if ($object->isCategoriesLoaded()) { //remove the back reference if available $object->getCategories()->removeObject($this); } $objectCategory->setCategory($this); $this->removeObjectCategory(clone $objectCategory); $objectCategory->clear(); $this->collObjects->remove($this->collObjects->search($object)); if (null === $this->objectsScheduledForDeletion) { $this->objectsScheduledForDeletion = clone $this->collObjects; $this->objectsScheduledForDeletion->clear(); } $this->objectsScheduledForDeletion->push($object); } return $this; }
/** * @param ChildObject $object The ChildObject object to remove. * @return $this|ChildSport The current object (for fluent API support) */ public function removeObject(ChildObject $object) { if ($this->getObjects()->contains($object)) { $pos = $this->collObjects->search($object); $this->collObjects->remove($pos); if (null === $this->objectsScheduledForDeletion) { $this->objectsScheduledForDeletion = clone $this->collObjects; $this->objectsScheduledForDeletion->clear(); } $this->objectsScheduledForDeletion[] = clone $object; $object->setSport(null); } return $this; }