/** * Store at postFlush event because file namer mey need entity id, at prePersist event * system does not now auto generated entity id * @param \Doctrine\Common\EventArgs $args */ public function postFlush(EventArgs $args) { if (!$this->deferredFiles) { return; } foreach ($this->deferredFiles as $obj) { if (!$this->deferredFiles[$obj]) { continue; } foreach ($this->deferredFiles[$obj] as $mapping) { $fileData = $this->fileStorage->upload($mapping, $this->deferredFiles[$obj][$mapping]); $mapping->setFileDataPropertyValue($fileData); } unset($this->deferredFiles[$obj]); $this->dataStorage->postFlush($obj, $args); } }