Two Entities GalleryAlbum and GalleryImage have OneToMany/ManyToOne relationship:
One GalleryAlbum ==== can have ====> Many Ga
The first time you call persist doctrine will only save $album and not its images. You must specify that you want doctrine to cascade the persist by specifying it in the $images declaration:
/**
* @ORM\OneToMany(targetEntity="GalleryImage", mappedBy="parent", cascade={"persist", "remove"})
*/
protected $images;
This way when you call persist($album) it will also persist your images and should trigger preUpload in your GalleryImage. There are a few different options available for cascading and they are explained well here:
Doctrine transitive persistence cascade operations