/** * @param File $file * @param string $target * @param string $name * * @return File * * @throws FileNotFoundException */ public function moveFileToUuidDir(File $file, $target, $name) { if (file_exists($file->getFileName())) { $uuid = $this->UUIDGenerator->generateFromUrl($name); $newDirectory = $this->createDirs($uuid, $target); $this->createDirIfNotExist($newDirectory); $newFileName = $newDirectory . DIRECTORY_SEPARATOR . $uuid; $file->setDirectories($newDirectory); if ($file->isTemp()) { $this->renameTempFile($file, $newFileName); } else { $file = $this->renameFile($file, $uuid); } $file->setFileName($uuid); $file->setUUID($uuid); } else { throw new FileNotFoundException(); } return $file; }