本文整理汇总了PHP中League\Flysystem\FilesystemInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::get方法的具体用法?PHP FilesystemInterface::get怎么用?PHP FilesystemInterface::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serveFromSource
/**
* Process a source image and Generate a response object
*
* @param String $path Path to the source image
* @return Boolean
*/
private function serveFromSource($path)
{
//try and load the image from the source
if ($this->source->has($path)) {
$file = $this->source->get($path);
// Get the template object
$template = $this->templates[$this->template]();
// Process the image
$image = $this->processImage($file, $this->imageManager, $template);
// Set the headers
$this->response->headers->set('Content-Type', $image->mime);
$this->response->headers->set('Content-Length', strlen($image->encoded));
$lastModified = new \DateTime();
// now
$this->setHttpCacheHeaders($lastModified, md5($this->getCachePath() . $lastModified->getTimestamp()), $this->maxAge);
// Send the processed image in the response
$this->response->setContent($image->encoded);
// Setup a callback to write the processed image to the cache
// This will be called after the image has been sent to the browser
$this->cacheWrite = function (FilesystemInterface $cache, $path) use($image) {
// use put() to write or update
$cache->put($path, $image->encoded);
};
return true;
}
return false;
}
示例2: getFileInfoByIdentifier
/**
* Returns information about a file.
*
* @param string $fileIdentifier
* @param array $propertiesToExtract Array of properties which are be extracted
* If empty all will be extracted
* @return array
* @throws FileDoesNotExistException
*/
public function getFileInfoByIdentifier($fileIdentifier, array $propertiesToExtract = [])
{
$relativeDriverPath = ltrim($fileIdentifier, '/');
if (!$this->filesystem->has($relativeDriverPath) || !$this->filesystem->get($relativeDriverPath)->isFile()) {
throw new FileDoesNotExistException('File ' . $fileIdentifier . ' does not exist.', 1314516809);
}
$dirPath = PathUtility::dirname($fileIdentifier);
$dirPath = $this->canonicalizeAndCheckFolderIdentifier($dirPath);
return $this->extractFileInformation($relativeDriverPath, $dirPath, $propertiesToExtract);
}
示例3: setFile
/**
* Sets the file to stream.
*
* @param \SplFileInfo|string $file The file to stream
* @param string $contentDisposition
* @param bool $autoEtag
*
* @return BinaryFileResponse
*
* @throws FileException
*/
public function setFile($file, $contentDisposition = null, $autoEtag = false)
{
if ($file instanceof File) {
$file->setFilesystem($this->filesystem);
} else {
$file = $this->filesystem->get($file);
}
if (!$this->filesystem->has($file->getPath())) {
throw new FileException('File must be readable.');
}
$this->file = $file;
if ($autoEtag) {
$this->setAutoEtag();
}
if ($contentDisposition) {
$this->setContentDisposition($contentDisposition);
}
return $this;
}
示例4: __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;
}
示例5: get
/**
* Get a file/directory handler.
*
* @param string $path The path to the file.
* @param Handler $handler An optional existing handler to populate.
*
* @return Handler Either a file or directory handler.
*/
public function get($path, Handler $handler = null)
{
return $this->fileSystem->get($path, $handler);
}