本文整理汇总了PHP中League\Flysystem\FilesystemInterface::update方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::update方法的具体用法?PHP FilesystemInterface::update怎么用?PHP FilesystemInterface::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdate
/**
* @dataProvider adapterProvider
*/
public function testUpdate(FilesystemInterface $filesystem, $adapter, $mock)
{
$mock->shouldReceive('put')->andReturn(true, false);
$mock->shouldReceive('stat')->andReturn(['type' => NET_SFTP_TYPE_DIRECTORY, 'mtime' => time(), 'size' => 20, 'permissions' => 0777]);
$this->assertTrue($filesystem->update('something', 'something'));
$this->assertFalse($filesystem->update('something_else.txt', 'else'));
}
示例2: write
/**
* Write settings content of a namespace
*
* @param string $namespace
* @param array $data
* @return void
*/
protected function write($namespace, array $data)
{
$file = $this->adapter->getFileName($namespace);
$contents = $this->adapter->prepareForWriting($data);
if (!$this->fileSystem->has($file)) {
$this->fileSystem->write($file, $contents);
}
$this->fileSystem->update($file, $contents);
}
示例3: erase
/**
* Erase a file.
*
* @param string $path
* @throws IoWriteException
*/
public function erase($path)
{
try {
$this->fs->update($path, '');
} catch (Error $ex) {
throw new IoWriteException("File {$path} could not be erased.", $ex);
} catch (Exception $ex) {
throw new IoWriteException("File {$path} could not be erased.", $ex);
}
}
示例4: renameConflicts
/** @inheritdoc */
public function renameConflicts(array $conflicts)
{
$replacements = [];
$this->traverser->addVisitor($this->reNamer);
foreach ($conflicts as $package => $types) {
foreach ($types as $type => $versions) {
foreach ($versions as $version => $files) {
$composer = $this->reader->setPackage($package)->setVersion($version)->getComposerObject();
if ($this->hasNs($type)) {
$split = $this->splitNsandClass($type);
$fromNs = $split['ns'];
$psrNs = $this->getPsrNs($composer, $fromNs);
$toNs = $psrNs . $this->sanitizeVersionNo($version);
$diff = str_replace($psrNs, '', $fromNs);
if ($psrNs != $diff . '\\') {
$toNs = $toNs . '\\' . $diff;
}
$newFullyQualifiedType = $toNs . '\\' . $split['class'];
} else {
$fromNs = $type;
$toNs = $type . '_' . $this->sanitizeVersionNo($version);
$newFullyQualifiedType = $toNs;
}
$this->reNamer->rename($fromNs, $toNs);
$replacements[] = ['package' => $package, 'version' => $version, 'originalFullyQualifiedType' => $type, 'originalNamespace' => $fromNs, 'newFullyQualifiedType' => $newFullyQualifiedType, 'newNamespace' => $toNs, 'replacedIn' => $files];
foreach ($files as $file) {
$fullPath = $this->vendorDir . '/' . $package . '/' . $version . '/' . $file;
$src = $this->filesystem->read($fullPath);
$ast = $this->parser->parse($src);
$newAst = $this->traverser->traverse($ast);
$code = $this->prettyPrinter->prettyPrintFile($newAst);
$this->filesystem->update($fullPath, $code);
}
}
}
}
$this->traverser->removeVisitor($this->reNamer);
return $replacements;
}
示例5: backupAndUpdate
private function backupAndUpdate($path, $content)
{
if ($this->enableBackup) {
$oldContent = $this->master->read($path);
if ($oldContent !== false) {
if ($this->backup->has($path)) {
$this->backup->update($path, $oldContent);
} else {
$this->backup->write($path, $oldContent);
}
}
}
$this->master->update($path, $content);
}
示例6: update
/**
* Update an existing file.
*
* @param string $path The path of the existing file.
* @param string $contents The file contents.
* @param array $config An optional configuration array.
*
* @throws FileNotFoundException
*
* @return bool True on success, false on failure.
*/
public function update($path, $contents, array $config = [])
{
return $this->fileSystem->update($path, $contents, $config);
}
示例7: mirrorFile
/**
* @param string $path
* @param FilesystemInterface $remote
* @param AdapterInterface $remoteAdapter
*/
private function mirrorFile($path, FilesystemInterface $remote, AdapterInterface $remoteAdapter)
{
$masterContent = $this->master->read($path);
if (!is_string($masterContent)) {
throw new \RuntimeException(sprintf('File %s could not be read on master storage', $path));
}
$isOnRemote = $remote->has($path);
if ($isOnRemote && !$remote->update($path, $masterContent)) {
throw $this->createRuntimeException('File', $path, 'updated', $remoteAdapter);
} elseif (!$isOnRemote && !$remote->write($path, $masterContent)) {
throw $this->createRuntimeException('File', $path, 'created', $remoteAdapter);
}
}