/** * Remove batch of this object * through the R_batch_forbook cross reference table. * * @param ChildBatch $batch * @return ChildBooks The current object (for fluent API support) */ public function removeBatch(ChildBatch $batch) { if ($this->getBatches()->contains($batch)) { $rBatchForbook = new ChildRBatchForbook(); $rBatchForbook->setBatch($batch); if ($batch->isBookssLoaded()) { //remove the back reference if available $batch->getBookss()->removeObject($this); } $rBatchForbook->setBooks($this); $this->removeRBatchForbook(clone $rBatchForbook); $rBatchForbook->clear(); $this->collBatches->remove($this->collBatches->search($batch)); if (null === $this->batchesScheduledForDeletion) { $this->batchesScheduledForDeletion = clone $this->collBatches; $this->batchesScheduledForDeletion->clear(); } $this->batchesScheduledForDeletion->push($batch); } return $this; }