images = new \Doctrine\Common\Collections\ArrayCollection(); } public function getId() { return $this->id; } public function addImage(Image $image) { $this->images[] = $image; } public function setImages(array $images) { foreach ($images as $img) { // first check if it does not contain it allready // because all entity objects are allready in memory // simply $em->find('Image', $id); and you will get it from this collection if (!$this->images->contains($img)) { $this->addImage($img); } } } public function getImages() { return $this->images; } public function addFile(File $file) { $this->files[] = $file; } public function getFiles() { return $this->files; } public function setTitle($title) { $this->title = $title; } public function getTitle() { return $this->title; } }