/** * Checks for for file to upload and store it for store at postFlush event * * @param \Doctrine\Common\EventArgs $args The event arguments. */ public function prePersist(EventArgs $args) { $obj = $this->dataStorage->getObjectFromArgs($args); $mappings = $this->mappingFactory->getMappingsFromObject($obj, $this->dataStorage->getReflectionClass($obj)); $curFiles = new \SplObjectStorage(); foreach ($mappings as $mapping) { $file = $mapping->getFileUploadPropertyValue(); if ($file instanceof File) { $curFiles[$mapping] = $file; } $mapping->setFileUploadPropertyValue(null); } //if ($curFiles) $this->deferredFiles [$mappings[0]->getObj()] = $curFiles; if (count($curFiles)) { $this->deferredFiles[$obj] = $curFiles; } }
public function fromEventArgs(EventArgs $args) { $obj = $this->dataStorage->getObjectFromArgs($args); return $this->fromObject($obj); }