本文整理汇总了PHP中League\Flysystem\Filesystem::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::write方法的具体用法?PHP Filesystem::write怎么用?PHP Filesystem::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Write content into file. If file exists it will be overwritten.
*
* @param $path
* @param $contents
*/
public function write($path, $contents)
{
if ($this->filesystem->has($path)) {
$this->remove($path);
}
$this->filesystem->write($path, $contents);
}
示例2: write
protected function write($data)
{
$destination = $this->composer->getClassPath($this->data['name']);
if ($this->force && $this->external->has($destination)) {
$this->external->delete($destination);
}
return $this->external->write($destination, $data);
}
示例3: installParts
protected function installParts()
{
$config = new \stdClass();
foreach ($this->parts as $part) {
$part->setupPackage($config, $this->filesystem);
}
$this->filesystem->write('composer.json', json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
示例4: loadFile
/**
* @return false|string
*/
private function loadFile()
{
if (!$this->filesystem->has($this->getFile())) {
$this->filesystem->write($this->getFile(), '');
}
if (!$this->sites) {
$this->sites = $this->filesystem->read($this->file);
}
return $this->sites;
}
示例5: publish
/**
* @param File $file
* @param Version $version
* @param VersionProvider $versionProvider
* @param Linker $linker
* @return bool
*/
public function publish(File $file, Version $version, VersionProvider $versionProvider, Linker $linker)
{
$path = $linker->getLink($file, $version, $versionProvider->getExtension($file, $version));
$tmp = $this->storage->retrieveVersion($versionProvider->getApplicableVersionable($file), $version);
if ($this->filesystem->has($path)) {
return false;
}
$this->filesystem->write($path, file_get_contents($tmp), ['visibility' => AdapterInterface::VISIBILITY_PUBLIC]);
return true;
}
示例6: publish
/**
* @param string $content
* @param string $path
* @return bool
* @throws \InvalidArgumentException
* @throws \League\Flysystem\FileNotFoundException
*/
public function publish($content, $path = '')
{
if (empty($path)) {
throw new \InvalidArgumentException('Path is mandatory!');
}
$config = new Config();
try {
return $this->storage->write($path, $content, $config);
} catch (FileExistsException $e) {
return $this->storage->update($path, $content, $config);
}
}
示例7: convert
public function convert($filePathIn, $filePathOut)
{
$replace = [];
$replace['js_app'] = file_get_contents(__DIR__ . "/../../templates/{$this->usedTemplate}/" . "{$this->usedTemplate}.js");
$replace['js_bootstrap'] = file_get_contents(self::PATH_DIST_BOOTSTRAP_JS);
$replace['css_app'] = file_get_contents(__DIR__ . "/../../templates/{$this->usedTemplate}/" . "{$this->usedTemplate}.css");
$replace['css_bootstrap'] = file_get_contents(self::PATH_DIST_BOOTSTRAP_CSS);
$replace['content'] = $this->mdParser->parse(file_get_contents($filePathIn));
$output['html'] = $this->latte->renderToString(__DIR__ . "/../../templates/{$this->usedTemplate}/" . "{$this->usedTemplate}.latte", $replace);
$output['pdf'] = "@todo :)";
$this->fs->write("{$filePathOut}.html", $output['html']);
$this->fs->write("{$filePathOut}.pdf", $output['pdf']);
}
示例8: writeToFile
/**
* @return bool
*/
private function writeToFile()
{
$this->filesystem->write($this->file, $this->template);
$this->out->writeln("Written endpoint wrapper to :" . $this->filesystem->get($this->file)->getPath());
$this->out->writeln("Class " . $this->className . " is generated");
return $this;
}
示例9: run
public function run()
{
$log = new Stream('php://stdout');
/** @var Config $config */
$config = Di::getDefault()->getShared('config');
$expireDate = new DateTime('now', new DateTimeZone('UTC'));
$expireDate->modify('+1 month');
$baseUrl = rtrim($config->get('site')->url, '/');
$content = <<<EOL
User-agent: *
Allow: /
Sitemap: {$baseUrl}/sitemap.xml
EOL;
$adapter = new Local(dirname(dirname(__FILE__)) . '/public');
$filesystem = new Filesystem($adapter);
if ($filesystem->has('robots.txt')) {
$result = $filesystem->update('robots.txt', $content);
} else {
$result = $filesystem->write('robots.txt', $content);
}
if ($result) {
$log->info('The robots.txt was successfully updated');
} else {
$log->error('Failed to update the robots.txt file');
}
}
示例10: write
public function write($path, $contents, array $config = [])
{
if (parent::write($path, $contents, $config)) {
return $this->getAdapter()->getModel();
} else {
return false;
}
}
示例11: write
/**
* Write a new file.
*
* @param string $path The path of the new file.
* @param string $contents The file contents.
* @param array $config An optional configuration array.
*
* @throws FileExistsException
*
* @return bool True on success, false on failure.
*/
public function write($path, $contents, array $config = [])
{
$result = parent::write($path, $contents, $config);
if ($result && ($resource = $this->get($path))) {
return $this->dispatch(new SyncFile($resource));
}
return $result;
}
示例12: writeFile
/**
* Write a new file from File.
*
* @param File $file File object
*
* @throws FileExistsException
*
* @return bool True on success, false on failure.
*/
public function writeFile(File $file)
{
try {
return $this->filesystem->write($file->getDirectories() . $file->getFileName(), $file->getResource(), []);
} catch (FlysystemFileExistsException $e) {
FileExistsException::fileExists();
}
}
示例13: _mkfile
/**
* @inheritdoc
*/
protected function _mkfile($path, $name)
{
$path = $this->_joinPath($path, $name);
if ($this->fs->write($path, '')) {
return $path;
}
return false;
}
示例14: copyTo
protected function copyTo($file, Filesystem $target, $targetName = null, Closure $handler = null)
{
$targetName = $targetName ?: basename($file);
$content = file_get_contents($file);
if ($handler) {
$content = $handler($content);
}
$target->write($targetName, $content);
}
示例15: writeSkipSeries
/**
* Create skip file to lessons
*/
public function writeSkipSeries()
{
$file = SERIES_FOLDER . '/.skip';
$series = serialize($this->getSeries());
if ($this->system->has($file)) {
$this->system->delete($file);
}
$this->system->write($file, $series);
}