/** * @param ChildFile $file The ChildFile object to remove. * @return $this|ChildNote The current object (for fluent API support) */ public function removeFile(ChildFile $file) { if ($this->getFiles()->contains($file)) { $pos = $this->collFiles->search($file); $this->collFiles->remove($pos); if (null === $this->filesScheduledForDeletion) { $this->filesScheduledForDeletion = clone $this->collFiles; $this->filesScheduledForDeletion->clear(); } $this->filesScheduledForDeletion[] = clone $file; $file->setNote(null); } return $this; }