public function __construct(AbstractSource $source) { // copy all the attributes $this->fileName = $source->getFileName(); $this->fileExtension = $source->getFileExtension(); $this->displayName = $source->getDisplayName(); $this->filePath = $source->getFilePath(); $this->fileSize = $source->getFileSize(); $this->mimeType = $source->getMimeType(); }
/** * @param AbstractSource $source */ public function store(AbstractSource $source) { $this->checkDir(); // TODO: create a dir by date, and save the source file TODO: should be able to // config this behaviour // FIXME: currently just store in the path directly if ($source instanceof UploadedFile) { $src = $source->getFilePath(); $dst = $this->getDstPath($source); $moved = @move_uploaded_file($src, $dst); if (!$moved) { throw new RuntimeException('can\'t move file from ' . $src . ' to ' . $dst); } } // generate the meta, save as attribute $this->meta = new FileMeta($source); $this->meta->setUrl($this->urlUtil->getUrl($source->getFilePath())); }