parentFolder = $parentFolder; } public function getPathToPhoto(Album $album, Photo $photo) { return sprintf('%s/%s', $this->getPathToAlbum($album), $photo->file_name); } public function saveUploadedPhoto(Album $album, File $uploadedFile) { $tempFilename = sprintf('%s/photo_%s', $this->getPathToAlbum($album), MiscHelper::randomString(20)); $extension = $uploadedFile->guessExtension(); if (!is_null($extension)) { $tempFilename .= '.' . $extension; } $uploadedFile->move(dirname($tempFilename), basename($tempFilename)); return new File($tempFilename); } private function getPathToAlbum(Album $album) { return sprintf('%s/albums/%s', $this->parentFolder, $album->url_alias); } }