本文整理汇总了PHP中League\Flysystem\FilesystemInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface类的具体用法?PHP FilesystemInterface怎么用?PHP FilesystemInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilesystemInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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]);
}
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:7,代码来源:RawFileFetcherSpec.php
示例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;
}
开发者ID:cass-project,项目名称:cass,代码行数:8,代码来源:MockAvatarStrategy.php
示例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);
}
开发者ID:whismat,项目名称:glide,代码行数:15,代码来源:PsrResponseFactory.php
示例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();
}
开发者ID:hanneskod,项目名称:yaysondb,代码行数:13,代码来源:FlysystemEngine.php
示例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();
}
开发者ID:ValentinGot,项目名称:trakt-api-wrapper,代码行数:15,代码来源:Method.php
示例6: __construct
/**
* @param FilesystemInterface $filesystem
* @param string $fileName
*
* @throws StorageException
*/
public function __construct(FilesystemInterface $filesystem, $fileName = self::DEFAULT_FILENAME)
{
if (!$filesystem->has($fileName)) {
$filesystem->write($fileName, '');
}
$handler = $filesystem->get($fileName);
if (!$handler->isFile()) {
throw new StorageException(sprintf('Expected path "%s" to be a file but its a "%s".', $handler->getPath(), $handler->getType()));
}
$this->file = $handler;
}
开发者ID:baleen,项目名称:storage-flysystem,代码行数:17,代码来源:FlyStorage.php
示例7: getPaths
protected function getPaths(FilesystemInterface $filesystem, $skipDirs)
{
$paths = [];
foreach ($filesystem->listContents($this->dir, true) as $path) {
if ($skipDirs && $path['type'] === 'dir') {
continue;
}
$paths[$path['path']] = $path;
}
ksort($paths);
return $paths;
}
开发者ID:repat,项目名称:flysystem-sync,代码行数:12,代码来源:Sync.php
示例8: create
/**
* Create response.
*
* @param \League\Flysystem\FilesystemInterface $cache Cache file system.
* @param string $path Cached file path.
*
* @return \Psr\Http\Message\ResponseInterface Response object.
*/
public function create(FilesystemInterface $cache, $path)
{
$stream = new Stream($cache->readStream($path));
$contentType = $cache->getMimetype($path);
$contentLength = (string) $cache->getSize($path);
if ($contentType === false) {
throw new FilesystemException('Unable to determine the image content type.');
}
if ($contentLength === false) {
throw new FilesystemException('Unable to determine the image content length.');
}
return (new Response())->withBody($stream)->withHeader('Content-Type', $contentType)->withHeader('Content-Length', $contentLength);
}
开发者ID:admad,项目名称:cakephp-glide,代码行数:21,代码来源:PsrResponseFactory.php
示例9: fetch
/**
* {@inheritdoc}
*/
public function fetch(FileInterface $file, FilesystemInterface $filesystem)
{
if (!$filesystem->has($file->getKey())) {
throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $file->getKey()));
}
$localPathname = tempnam(sys_get_temp_dir(), 'raw_file_fetcher_');
if (false === ($stream = $filesystem->readStream($file->getKey()))) {
throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $file->getKey()));
}
if (false === file_put_contents($localPathname, $stream)) {
throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $file->getKey()));
}
return new \SplFileInfo($localPathname);
}
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:17,代码来源:RawFileFetcher.php
示例10: 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);
}
}
开发者ID:kivagant,项目名称:staticus-core,代码行数:7,代码来源:DestroyResourceCommand.php
示例11: 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;
}
开发者ID:roelvanduijnhoven,项目名称:backup-email-check,代码行数:31,代码来源:Assert.php
示例12: 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;
}
开发者ID:dragosprotung,项目名称:stc-core,代码行数:11,代码来源:AbstractDumper.php
示例13: 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);
}
开发者ID:roelvanduijnhoven,项目名称:backup-email-check,代码行数:8,代码来源:AssertTest.php
示例14: getResource
public function getResource($spiBinaryFileId)
{
try {
return $this->filesystem->readStream($spiBinaryFileId);
} catch (FlysystemNotFoundException $e) {
throw new BinaryFileNotFoundException($spiBinaryFileId, $e);
}
}
开发者ID:Jenkosama,项目名称:ezpublish-kernel,代码行数:8,代码来源:Flysystem.php
示例15: 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));
}
}
开发者ID:brad-jones,项目名称:ppm,代码行数:9,代码来源:ProxyGenerator.php
示例16: delete
/**
* {@inheritdoc}
*/
public function delete($path)
{
try {
return $this->filesystem->delete($path);
} catch (FileNotFoundException $exception) {
return false;
}
}
开发者ID:svycka,项目名称:sv-images,代码行数:11,代码来源:FlySystemAdapter.php
示例17: 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) {
//
}
}
开发者ID:AltThree,项目名称:Storage,代码行数:15,代码来源:FlysystemStore.php
示例18: 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));
}
开发者ID:graundas,项目名称:LiipImagineBundle,代码行数:11,代码来源:FlysystemLoader.php
示例19: fromFile
/**
* {@inheritdoc}
*/
public function fromFile($file) : Workout
{
$content = $this->filesystem->read($file);
if ($content === false) {
throw new UnreadableFileException();
}
return $this->fromString($content);
}
开发者ID:dragosprotung,项目名称:stc-core,代码行数:11,代码来源:AbstractLoader.php
示例20: adapterType
protected function adapterType()
{
if ($this->filesystem instanceof Filesystem) {
$reflect = new \ReflectionClass($this->filesystem->getAdapter());
return $reflect->getShortName();
}
return 'Unknown';
}
开发者ID:aleksabp,项目名称:bolt,代码行数:8,代码来源:AdapterPlugin.php
注:本文中的League\Flysystem\FilesystemInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论