本文整理汇总了PHP中League\Flysystem\Filesystem::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::put方法的具体用法?PHP Filesystem::put怎么用?PHP Filesystem::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writePage
/**
* Start the site Scraping process.
*
* @param string $url
* @param \GuzzleHttp\Psr7\Stream $body
*
* @return void
*/
protected function writePage($url, $body)
{
$page = $this->getPage($url);
$body = str_replace($this->localSite, $this->remo, "{$body}");
$write = $this->fs->put($page, $body);
return $write;
}
示例2: slash
/**
* {@inheritdoc}
*/
public function slash()
{
$app_path = str_replace(config('path.root'), '', config()->path->app);
$arg_name = studly_case(str_slug($this->input->getArgument('name'), '_'));
$stub = file_get_contents(__DIR__ . '/stubs/makeRoute.stub');
$stub = stubify($stub, ['routeName' => $arg_name, 'prefixRouteName' => strtolower($arg_name)]);
$file_name = $arg_name . 'Routes.php';
$module = $this->input->getArgument('module');
$has_dir = is_dir(config()->path->app . $module);
if ($has_dir === false) {
$this->error('Module not found `' . $module . '`');
return;
}
$module = $this->input->getArgument('module');
if ($this->app->has($module) === false) {
$this->error('Module not found `' . $module . '`');
return;
}
$routes = $module . '/routes/';
if ($this->app->has($routes) === false) {
$this->error('Routes folder not found from your module: `' . $module . '`');
return;
}
$stub = stubify($stub, ['namespace' => path_to_namespace($app_path . $routes), 'controllerNamespace' => path_to_namespace($app_path . $module . '/controllers/')]);
$this->info('Crafting Route...');
if ($this->app->has($file_name)) {
$this->error(' Route already exists!');
return;
}
$this->app->put($routes . $file_name, $stub);
$this->info(' ' . $file_name . ' created!');
$this->callDumpAutoload();
}
示例3: testDeleteMockResourceExistsSizes
public function testDeleteMockResourceExistsSizes()
{
$resourceDO = $this->getResourceDOMock();
$this->filesystem->put($resourceDO->getFilePath(), '');
$resourceDOSize10x11 = $this->getResourceDOMock();
$resourceDOSize10x11->setWidth(10);
$resourceDOSize10x11->setHeight(11);
$this->filesystem->put($resourceDOSize10x11->getFilePath(), '');
$resourceDOSize20x21 = $this->getResourceDOMock();
$resourceDOSize20x21->setWidth(20);
$resourceDOSize20x21->setHeight(21);
$this->filesystem->put($resourceDOSize20x21->getFilePath(), '');
$yetAnotherWrongDO = clone $resourceDO;
$yetAnotherWrongDO->setWidth(998);
$yetAnotherWrongDO->setHeight(999);
$this->wrongFiles->create($resourceDO, 'Wrong1');
$this->wrongFiles->create($resourceDOSize10x11, 'Wrong2');
$this->wrongFiles->create($resourceDOSize20x21, 'Wrong3');
$this->wrongFiles->create($yetAnotherWrongDO, 'Wrong4');
$modelFiles = $this->filesystem->listContents('/', true);
// Make the expected model looks like filesystem after the command execution
// With this model we will be sure that other files have not been deleted
unset($modelFiles[56], $modelFiles[57]);
$modelFiles[55] = ['type' => 'dir', 'path' => 'testBase/png/def/def/0/c9f/20x21', 'dirname' => 'testBase/png/def/def/0/c9f', 'basename' => '20x21', 'filename' => '20x21'];
$command = $this->getCommand($resourceDO);
$result = $command();
$this->assertTrue($result);
$this->assertFalse($this->filesystem->has($resourceDOSize10x11->getFilePath()));
$this->assertFalse($this->filesystem->has($resourceDOSize20x21->getFilePath()));
$result = $this->filesystem->listContents('/', true);
$this->assertEquals($modelFiles, $result);
}
示例4: write
/**
* {@inheritdoc}
*/
public function write(Configuration $configuration)
{
$ini = $this->getRenderer()->render($configuration->toArray());
if (false === ($result = $this->filesystem->put($this->file, $ini))) {
throw new WriterException(sprintf('Cannot write configuration into file %s', $this->file));
}
return $result;
}
示例5: storeVersion
public function storeVersion(Versionable $versionable, Version $version, $tempFile)
{
$pathName = $this->getVersionPathName($versionable, $version);
$ret = $this->filesystem->put($pathName, file_get_contents($tempFile), ['visibility' => AdapterInterface::VISIBILITY_PRIVATE]);
if (!$ret) {
throw new FileIOException(sprintf("Failed to store version '%s' of versionable %s;%s", $version->toString(), get_class($versionable), $versionable->getId()));
}
return new Retrieved($tempFile);
}
示例6: write
public function write($id, $config, array $options = [])
{
$this->id = $id;
$this->config = $config;
$this->timestamp = time();
if (!$this->filesystem->put($this->getPathFromId($id), $this->dump(['lunch_guy' => $config]))) {
throw new \RuntimeException("Failed to write configuration {$id}");
}
}
示例7: download
/**
* Downloads a request
*
* @param RequestInterface $request
*
* @return boolean
*/
public function download(RequestInterface $request, $path)
{
$response = $this->httpAdapter->sendRequest($request);
if (!($body = $response->getBody())) {
return false;
}
$stream = $body->detach();
if (is_resource($stream)) {
return $this->filesystem->putStream($path, $stream);
}
return $this->filesystem->put($path, $stream);
}
示例8: getData
/**
* Returns the historical price data as a csv string for $ticker
* @param string $ticker
* @param bool $fromCache
* @param bool $saveToCache
* @param bool $return
* @return TickerCollection
*/
public function getData($ticker, $fromCache = true, $saveToCache = true, $return = true)
{
if ($fromCache && $this->fileSystem->has($ticker)) {
return $this->present($ticker, $this->fileSystem->read($ticker));
}
$data = (string) $this->guzzle->request('GET', '', ['query' => ['s' => $ticker, 'ignore' => '.csv']])->getBody();
if ($saveToCache) {
$this->fileSystem->put($ticker, $data);
}
if ($return) {
return $this->present($ticker, $data);
}
}
示例9: testFindVersion8
public function testFindVersion8()
{
$resourceDO_v0 = $this->getResourceDOMock();
$this->filesystem->put($resourceDO_v0->getFilePath(), '');
// Put one more version on disk
$expectedVersion = $resourceDO_v0->getVersion() + 7;
$resourceDO_v1 = clone $resourceDO_v0;
$resourceDO_v1->setVersion($expectedVersion);
$this->filesystem->put($resourceDO_v1->getFilePath(), '');
$command = $this->getCommand($resourceDO_v0);
$result = $command();
$this->assertEquals($expectedVersion, $result);
}
示例10:
function it_throws_an_exception_when_configuration_cannot_be_written(Flysystem $filesystem, Renderer $renderer, Configuration $configuration)
{
$renderer->render($configuration)->willReturn('contents');
$filesystem->put('file', 'contents')->willReturn(false);
$this->beConstructedWith($filesystem, 'file', $renderer);
$this->shouldThrow('Indigo\\Supervisor\\Exception\\WrittingFailed')->duringWrite($configuration);
}
示例11: testDestroyResourceAllVariantsAndVersions
public function testDestroyResourceAllVariantsAndVersions()
{
$resourceDO = $this->getResourceDOMock();
$this->filesystem->put($resourceDO->getFilePath(), '');
$resourceDO_v2 = clone $resourceDO;
$resourceDO_v2->setVersion(2);
$this->filesystem->put($resourceDO_v2->getFilePath(), '');
$resourceDO_var1 = clone $resourceDO;
$resourceDO_var1->setVariant('1');
$this->filesystem->put($resourceDO_var1->getFilePath(), '');
// variant version must be deleted too
$resourceDO_var1_v1 = clone $resourceDO_var1;
$resourceDO_var1_v1->setVersion(1);
$this->filesystem->put($resourceDO_var1_v1->getFilePath(), '');
$resourceDO_var2 = clone $resourceDO;
$resourceDO_var2->setVariant('2');
$this->filesystem->put($resourceDO_var2->getFilePath(), '');
$resourceDO_var2_v1 = clone $resourceDO_var2;
$resourceDO_var2_v1->setVersion(2);
$this->filesystem->put($resourceDO_var2_v1->getFilePath(), '');
$command = $this->getCommand($resourceDO);
$result = $command();
$this->assertEquals($resourceDO, $result);
$this->assertFalse($this->filesystem->has($resourceDO_var1->getFilePath()));
$this->assertFalse($this->filesystem->has($resourceDO_var1_v1->getFilePath()));
$this->assertFalse($this->filesystem->has($resourceDO_v2->getFilePath()));
$this->assertFalse($this->filesystem->has($resourceDO_var2->getFilePath()));
$this->assertFalse($this->filesystem->has($resourceDO_var2_v1->getFilePath()));
$this->assertFalse($this->filesystem->has($resourceDO->getFilePath()));
}
示例12: testPutUpdate
public function testPutUpdate()
{
$path = 'path.txt';
$contents = 'contents';
$this->prophecy->has($path)->willReturn(true);
$this->prophecy->update($path, $contents, $this->config)->willReturn(compact('path', 'contents'));
$this->assertTrue($this->filesystem->put($path, $contents));
}
示例13: put
/**
* @inheritdoc
*/
public function put($path, $contents, array $config = [])
{
if (parent::put($path, $contents, $config)) {
return $this->getAdapter()->getModel();
} else {
return false;
}
}
示例14: testBackupResourceWhenAnotherCopyAlreadyExist
public function testBackupResourceWhenAnotherCopyAlreadyExist()
{
$resourceDO_v0 = $this->getResourceDOMock();
$this->filesystem->put($resourceDO_v0->getFilePath(), '');
// Put one more version on disk
$resourceDO_v1 = clone $resourceDO_v0;
$resourceDO_v1->setVersion($resourceDO_v0->getVersion() + 1);
$this->filesystem->put($resourceDO_v1->getFilePath(), '');
$expectedVersion = (string) ($resourceDO_v0->getVersion() + 2);
$command = $this->getCommand($resourceDO_v0);
$result = $command();
$this->assertInstanceOf(ResourceDOInterface::class, $result);
$this->assertEquals($expectedVersion, $result->getVersion());
$resourceDO_v2 = clone $resourceDO_v0;
$resourceDO_v2->setVersion($expectedVersion);
$this->assertTrue($this->filesystem->has($resourceDO_v2->getFilePath(), ''));
}
示例15: createFile
/**
* Creates/uploads/updates a file on oc remote
*
* @param string $localPath File on local server
* @param string $remotePath File on oc Server
* @throws FileNotFoundException
* @return bool
*
*/
public function createFile($localPath, $remotePath = '')
{
//if local file not exists throw exception
if (!file_exists($localPath)) {
throw new FileNotFoundException("OwncloudApi: Local file not found");
}
//otherwise upload to server
return $this->fs->put($remotePath, file_get_contents($localPath));
}