/** * {@inheritdoc} */ public function toFile(Workout $workout, string $outputFile) : bool { $return = $this->filesystem->put($outputFile, $this->toString($workout)); if ($return !== true) { throw new Exception(sprintf('Could not write to %s', $outputFile)); } return true; }
/** @inheritdoc */ public function generate(array $replacements, $autoloader) { ReflectionEngine::init(new Locator($autoloader)); foreach ($replacements as $replacement) { $fullPath = $this->vendorDir . '/' . $replacement['package'] . '/proxy/' . str_replace('\\', '/', $replacement['originalFullyQualifiedType']) . ".php"; $this->filesystem->put($fullPath, $this->buildClass($replacement)); } }
/** * Write the contents of a file. * * @param string $path * @param string|resource $contents * @param string $visibility * * @return bool */ public function put($path, $contents, $visibility = null) { $config = ['visibility' => $this->parseVisibility($visibility)]; if (is_resource($contents)) { return $this->driver->putStream($path, $contents, $config); } return $this->driver->put($path, $contents, $config); }
/** * @param $filePath * @param $content */ protected function writeFile($filePath, $content) { if (is_resource($content)) { $result = $this->filesystem->putStream($filePath, $content); } else { $result = $this->filesystem->put($filePath, $content); } if (!$result) { throw new SaveResourceErrorException('File cannot be written to the path ' . $filePath); } }
/** * Write the contents of a file. * * @param string $path * @param string|resource $contents * @param array $options * @return bool */ public function put($path, $contents, $options = []) { if (is_string($options)) { $options = ['visibility' => $options]; } if ($contents instanceof File || $contents instanceof UploadedFile) { return $this->putFile($path, $contents, $options); } if (is_resource($contents)) { return $this->driver->putStream($path, $contents, $options); } else { return $this->driver->put($path, $contents, $options); } }
/** * Write session data * @link http://php.net/manual/en/sessionhandlerinterface.write.php * @param string $session_id The session id. * @param string $session_data <p> * The encoded session data. This data is the * result of the PHP internally encoding * the $_SESSION superglobal to a serialized * string and passing it as this parameter. * Please note sessions use an alternative serialization method. * </p> * @return bool <p> * The return value (usually TRUE on success, FALSE on failure). * Note this value is returned internally to PHP for processing. * </p> * @since 5.4.0 */ public function write($session_id, $session_data) { if (!$this->driver->has($path = $this->path . $session_id)) { $this->driver->create($path); } return $this->driver->put($path, $session_data); }
/** * Write the contents of a file. * * @param string $path * @param string|resource $contents * @param string $visibility * @return bool */ public function put($path, $contents, $visibility = null) { if ($contents instanceof File || $contents instanceof UploadedFile) { return $this->putFile($path, $contents, $visibility); } if ($visibility = $this->parseVisibility($visibility)) { $config = ['visibility' => $visibility]; } else { $config = []; } if (is_resource($contents)) { return $this->driver->putStream($path, $contents, $config); } else { return $this->driver->put($path, $contents, $config); } }
/** * @inheritdoc */ public function write($path, $contents, $append = false) { $path = $this->strategy->encode($path); if ($append === false && $this->filesystem->has($path)) { $this->filesystem->delete($path); } $this->filesystem->put($path, $contents); }
/** * @override * @inheritDoc */ public function createFile($path, $contents = '', $visibility = self::VISIBILITY_DEFAULT) { try { $this->fs->put($path, $contents, $this->prepareConfig($visibility)); return; } catch (Error $ex) { } catch (Exception $ex) { } throw new WriteException("File {$path} could not be created.", $ex); }
/** * Use flysystem to save the file in the desired location. * * @param \Onema\ClassyFile\Event\GetClassEvent $event */ public function onGetClassGenerateFile(GetClassEvent $event) { $statement = $event->getStatements(); $fileLocation = $event->getFileLocation(); $code = $event->getCode(); $name = $statement->name; if (!$this->filesystem->has($fileLocation)) { // dir doesn't exist, make it $this->filesystem->createDir($fileLocation); } $location = sprintf('%s/%s.php', $fileLocation, $name); $this->filesystem->put($location, $code); $adapter = $this->filesystem->getAdapter(); if ($adapter instanceof AbstractAdapter) { $prefix = $adapter->getPathPrefix(); $location = Util::normalizePath($location); $event->setFileLocation(sprintf('%s%s', $prefix, $location)); } }
/** * Create a file or update if exists. * * @param string $path * @param string $contents * @param string $visibility * @throws IoWriteException */ public function write($path, $contents = '', $visibility = self::VISIBILITY_DEFAULT) { try { $this->fs->put($path, $contents, $this->prepareConfig($visibility)); } catch (Error $ex) { throw new IoWriteException("File {$path} could not be overwritten.", $ex); } catch (Exception $ex) { throw new IoWriteException("File {$path} could not be overwritten.", $ex); } }
/** * Create a file or folder. * * @param string $path * @param string|null $contents */ protected function create($path, $contents = null) { // If the file already exists, quit $path = $this->formatPath($path); if ($this->filesystem->has($path)) { return; } // Create the file or folder if ($contents) { $this->filesystem->put($path, $contents); } else { $this->filesystem->createDir($path); } $this->output->writeln('<info>✓</info> Created <comment>' . $path . '</comment>'); }
/** * Downloads the packages zipball from github and extracts it. * * @param array $package The selected version of the package. * @return void */ private function downloadAndExtractPackageZipBall($package) { // NOTE: We actually use this list to determin if there are any stale // packages that need to be deleted, so we generate the list here // before we decide if we need to actually download the package or not. if (!isset($this->downloaded[$package['name']])) { $this->downloaded[$package['name']] = []; } if (!Linq::from($this->downloaded[$package['name']])->contains($package['version_normalized'])) { $this->downloaded[$package['name']][] = $package['version_normalized']; } $packagePath = $this->vendorDir . '/' . $package['name'] . '/' . $package['version_normalized']; if ($this->filesystem->has($packagePath)) { $this->notify("ALREADY HAVE PACKAGE\n"); return; } $url = $package['dist']['url']; $zipBall = $this->http->request('GET', $url)->getBody(); $zipBallPath = $packagePath . '/dist.zip'; $this->filesystem->put($zipBallPath, $zipBall); $this->zip->extract($zipBallPath, $packagePath); $this->filesystem->delete($zipBallPath); $this->notify("DONE\n"); }
/** * {@inheritdoc} */ public function put($path, $contents) { return $this->filesystem->put($path, $contents); }
/** @inheritdoc */ public function generate(array $installedPackages, array $renamedPackages) { $this->installedPackages = $installedPackages; $this->renamedPackages = $renamedPackages; $this->filesystem->put($this->vendorDir . '/autoload.php', $this->generateFile()); }
/** * Sets the contents of a file to the specified value. * * @param string $fileIdentifier * @param string $contents * @return int The number of bytes written to the file */ public function setFileContents($fileIdentifier, $contents) { $this->filesystem->put($fileIdentifier, $contents); return $this->filesystem->getSize($fileIdentifier); }
/** * Put an item into the storage. * * @param string $key * @param string $data * * @return void */ public function put($key, $data) { $this->flysystem->put($key, $data); }
/** * Create a file or update if exists. * * @param string $path The path to the file. * @param string $contents The file contents. * @param array $config An optional configuration array. * * @return bool True on success, false on failure. */ public function put($path, $contents, array $config = []) { return $this->fileSystem->put($path, $contents, $config); }
/** * Write the contents of a file. * * @param string $path * @param string $contents * @param string $visibility * @return bool */ public function put($path, $contents, $visibility = null) { return $this->driver->put($path, $contents, ['visibility' => $this->parseVisibility($visibility)]); }
/** * @param \livetyping\hermitage\foundation\entities\Image $image */ public function put(Image $image) { $this->filesystem->put($image->getPath(), $image->getBinary(), ['mimetype' => $image->getMimeType()]); }
/** * Write a string to a file * * @param string $path file path * @param string $content new file content * @return bool **/ protected function _filePutContents($path, $content) { return $this->fs->put($path, $content); }
/** * Generate source file from template. * * @param string $stub_path * @param array $arguments */ public function template($stub_path, array $arguments = []) { $this->outbox->put($this->context->file, $this->generate($this->read($stub_path), $arguments)); }