本文整理汇总了PHP中League\Flysystem\FilesystemInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface类的具体用法?PHP FilesystemInterface怎么用?PHP FilesystemInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilesystemInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FileTransferException
function it_throws_an_exception_when_the_file_can_not_be_read_on_the_filesystem(FileInterface $file, FilesystemInterface $filesystem)
{
$file->getKey()->willReturn('path/to/file.txt');
$filesystem->has('path/to/file.txt')->willReturn(true);
$filesystem->readStream('path/to/file.txt')->willReturn(false);
$this->shouldThrow(new FileTransferException('Unable to fetch the file "path/to/file.txt" from the filesystem.'))->during('fetch', [$file, $filesystem]);
}
示例2: touchDir
private function touchDir(FilesystemInterface $fs, string $entityId, string $collectionUID, string $imageId) : string
{
$resultPath = sprintf('%s/%s/%s', $entityId, $collectionUID, $imageId);
if (!$fs->has($resultPath)) {
$fs->createDir($resultPath);
}
return $resultPath;
}
示例3: create
/**
* Create response.
* @param FilesystemInterface $cache Cache file system.
* @param string $path Cached file path.
* @return Response Response object.
*/
public function create(FilesystemInterface $cache, $path)
{
$stream = $this->streamCallback->__invoke($cache->readStream($path));
$contentType = $cache->getMimetype($path);
$contentLength = (string) $cache->getSize($path);
$cacheControl = 'max-age=31536000, public';
$expires = date_create('+1 years')->format('D, d M Y H:i:s') . ' GMT';
return $this->response->withBody($stream)->withHeader('Content-Type', $contentType)->withHeader('Content-Length', $contentLength)->withHeader('Cache-Control', $cacheControl)->withHeader('Expires', $expires);
}
示例4: __construct
/**
* @throws FileNotFoundException If fname does not exist in filesystem
*/
public function __construct(string $fname, FilesystemInterface $fsystem, DecoderInterface $decoder = null)
{
if (!$fsystem->has($fname)) {
throw new FileNotFoundException("Unable to read file {$fname}");
}
$this->fname = $fname;
$this->fsystem = $fsystem;
$this->decoder = $decoder ?: $this->guessDecoder();
$this->reset();
}
示例5: __construct
/**
* @param ReflectionClass $reflection
* @param FilesystemInterface $filesystem
* @param null $name
*/
public function __construct(ReflectionClass $reflection, FilesystemInterface $filesystem, $name = null)
{
$this->reflection = $reflection;
$this->template = $filesystem->read("/Console/stubs/method.stub");
$this->name = $name;
$this->classParameters = $this->getClassParameters();
$this->uses = $this->getUsages();
$this->methodParameterNames = $this->getMethodParameters();
$this->requestParameters = $this->getRequestParameters();
}
示例6: deleteFile
protected function deleteFile($filePath)
{
// If file is already gone somewhere, it is OK for us
if ($this->filesystem->has($filePath) && !$this->filesystem->delete($filePath)) {
throw new CommandErrorException('The file cannot be removed: ' . $filePath);
}
}
示例7: assertBackups
/**
* Return string error message if not found to be correct
*
* @return string|bool
*/
public function assertBackups($today)
{
$day = $today;
$sizes = [];
for ($i = 0; $i < 2; $i++) {
$expected = 's77_mail_' . $day->format('Y-m-d') . '.tar.gz';
try {
$size = $this->filesystem->getSize($expected);
if ($size === false) {
return "Kan bestandsgrootte niet ophalen van '{$expected}'";
}
$sizes[] = $size;
if ($size < 3.4 * 1000 * 1000 * 1000) {
$humanSize = $size / 1000 / 1000;
return "Email backup lijkt te klein ({$humanSize} MB)";
}
} catch (\League\Flysystem\FileNotFoundException $e) {
return "Kon email backup niet vinden: '{$expected}'";
}
$day = $day->sub(new \DateInterval('P1D'));
}
if (count(array_unique($sizes)) === 1) {
return "Laatste twee e-mail backups zijn even groot.";
}
return true;
}
示例8: toFile
/**
* {@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;
}
示例9: testLastBackupsIdentical
public function testLastBackupsIdentical()
{
$meta = $this->getMeta(123123123123.0);
$this->fs->getSize('s77_mail_2015-04-22.tar.gz')->willReturn($meta);
$this->fs->getSize('s77_mail_2015-04-21.tar.gz')->willReturn($meta);
$result = $this->assert->assertBackups(new \DateTime('2015-04-22'));
$this->assertEquals("Laatste twee e-mail backups zijn even groot.", $result);
}
示例10: getResource
public function getResource($spiBinaryFileId)
{
try {
return $this->filesystem->readStream($spiBinaryFileId);
} catch (FlysystemNotFoundException $e) {
throw new BinaryFileNotFoundException($spiBinaryFileId, $e);
}
}
示例11: generate
/** @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));
}
}
示例12: delete
/**
* {@inheritdoc}
*/
public function delete($path)
{
try {
return $this->filesystem->delete($path);
} catch (FileNotFoundException $exception) {
return false;
}
}
示例13: delete
/**
* Delete an item from the storage if it exists.
*
* @param string $key
*
* @return void
*/
public function delete($key)
{
try {
$this->flysystem->delete($key);
} catch (FileNotFoundException $e) {
//
}
}
示例14: find
/**
* {@inheritdoc}
*/
public function find($path)
{
if ($this->filesystem->has($path) === false) {
throw new NotLoadableException(sprintf('Source image "%s" not found.', $path));
}
$mimeType = $this->filesystem->getMimetype($path);
return new Binary($this->filesystem->read($path), $mimeType, $this->extensionGuesser->guess($mimeType));
}
示例15: fromFile
/**
* {@inheritdoc}
*/
public function fromFile($file) : Workout
{
$content = $this->filesystem->read($file);
if ($content === false) {
throw new UnreadableFileException();
}
return $this->fromString($content);
}