本文整理汇总了PHP中Filesystem::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::put方法的具体用法?PHP Filesystem::put怎么用?PHP Filesystem::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFile
/**
* Process a php target file to append PHP syntax-sensitive content
* from multiple template sources.
*
* @param string $file, a php file to modify
* @param array $templates list of key (property name), value (template file)
* @param string $data used to replace placeholders inside all template files
* @param Boolean $front, set location to the front of the array
*/
protected function processFile($file, $templates, $data, $front = false)
{
$content = $this->files->get($file);
$phpParser = new GenericPhpParser($content, $data, $this->parser);
foreach ($templates as $property => $template) {
$phpParser->parse($property, $template, $front);
}
$content = $phpParser->prettyPrint();
if (!is_null($content)) {
$this->files->put($file, $content);
}
}
示例2: put
/**
* Write the contents of a file
*
* @param string $path
* @param string $contents
* @param bool $lock
* @return int
*/
public function put($path, $contents, $avoid = false, $lock = false)
{
return $this->files->put($path, $contents, $avoid, $lock);
}
示例3: exportToJson
private function exportToJson($sJsonFilePath, array $aData, $bCompress = false)
{
$sNewJsonContent = Conversion::getJsonFromArray($aData, $bCompress);
if (Filesystem::put($sJsonFilePath, $sNewJsonContent) !== false) {
return Filesystem::name($sJsonFilePath) . '.' . Filesystem::extension($sJsonFilePath);
} else {
throw new FileNotCreatedException('File : ' . $sJsonFilePath);
}
}
示例4: testFailingPut
public function testFailingPut()
{
$mock = \Mockery::mock('League\\Flysystem\\Adapter\\AbstractAdapter');
$cachemock = \Mockery::mock('League\\Flysystem\\Cache\\AbstractCache');
$cachemock->shouldReceive('load')->andReturn(array());
$cachemock->shouldReceive('has')->andReturn(false);
$cachemock->shouldReceive('isComplete')->andReturn(false);
$cachemock->shouldReceive('updateObject')->andReturn(false);
$mock->shouldReceive('__toString')->andReturn('Flysystem\\Adapter\\AbstractAdapter');
$cachemock->shouldReceive('__toString')->andReturn('Flysystem\\Cache\\AbstractCache');
$filesystem = new Filesystem($mock, $cachemock);
$mock->shouldReceive('write')->andReturn(false);
$mock->shouldReceive('update')->andReturn(false);
$mock->shouldReceive('has')->with('dummy.txt')->andReturn(true);
$this->assertFalse($filesystem->put('dummy.txt', 'content'));
$mock->shouldReceive('has')->with('dummy2.txt')->andReturn(false);
$this->assertFalse($filesystem->put('dummy2.txt', 'content'));
}