/** * Write the contents into the file * * @param string $fileName The full path to the file * @param string $contents The contents to write to the file * * @return boolean True on success */ public function write($fileName, $contents) { $ret = $this->fileAdapter->write($fileName, $contents); if (!$ret && is_object($this->abstractionAdapter)) { return $this->abstractionAdapter->write($fileName, $contents); } return $ret; }
/** * @param Storageable $storageable * @param \SplFileInfo $fileInfo * * @return bool */ public function store(Storageable $storageable, \SplFileInfo $fileInfo) : bool { $fileName = $this->namingStrategy->generate($storageable); $filePath = $this->filePathStrategy->generate($fileName); $fileExtension = $this->getFileExtension($fileInfo); if ($fileExtension) { $fileName .= '.' . $fileExtension; } $storageable->setFileName($fileName); $filePathWithName = $filePath . DIRECTORY_SEPARATOR . $fileName; if (!$this->filesystem->write($filePathWithName, file_get_contents($fileInfo->getPathname()))) { throw FileStoreException::notStored(); } return true; }