本文整理汇总了PHP中League\Flysystem\FilesystemInterface::read方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::read方法的具体用法?PHP FilesystemInterface::read怎么用?PHP FilesystemInterface::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: getContents
public function getContents($spiBinaryFileId)
{
try {
return $this->filesystem->read($spiBinaryFileId);
} catch (FlysystemNotFoundException $e) {
throw new BinaryFileNotFoundException($spiBinaryFileId, $e);
}
}
示例3: fromFile
/**
* {@inheritdoc}
*/
public function fromFile($file) : Workout
{
$content = $this->filesystem->read($file);
if ($content === false) {
throw new UnreadableFileException();
}
return $this->fromString($content);
}
示例4: read
/**
* {@inheritdoc}
*/
public function read($path)
{
try {
return $this->filesystem->read($path);
} catch (FileNotFoundException $exception) {
return false;
}
}
示例5: get
/**
* Get the contents of a file.
*
* @param string $path
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function get($path)
{
try {
return $this->driver->read($path);
} catch (FileNotFoundException $e) {
throw new ContractFileNotFoundException($path, $e->getCode(), $e);
}
}
示例6: get
/**
* Get an item from the storage.
*
* @param string $key
*
* @return string|null
*/
public function get($key)
{
try {
if ($data = $this->flysystem->read($key)) {
return $data;
}
} catch (FileNotFoundException $e) {
//
}
}
示例7: data
/**
* @param ServerRequestInterface $request
*
* @return mixed|null
*/
public function data(ServerRequestInterface $request)
{
$url = $request->getUri()->getPath();
$parameters = array_merge($request->getQueryParams(), $request->getParsedBody());
$file = $this->file($url, $parameters);
if (!$this->filesystem->has($file)) {
$file = $this->defaultFile($url);
}
if (!$this->filesystem->has($file)) {
return null;
}
return $this->filesystem->read($file);
}
示例8: load
/**
* {@inheritDoc}
*/
public function load($path)
{
try {
$contents = $this->filesystem->read($path);
} catch (FileNotFoundException $e) {
throw new Exception\ImageNotFoundException(sprintf('Source image not found in "%s"', $path));
}
$mimeType = $this->filesystem->getMimeType($path);
if ($mimeType === false) {
// Mime Type could not be detected
return $contents;
}
return new Binary($contents, $mimeType);
}
示例9: makeImage
/**
* Generate manipulated image.
* @param string $path Image path.
* @param array $params Image manipulation params.
* @return string Cache path.
* @throws FileNotFoundException
* @throws FilesystemException
*/
public function makeImage($path, array $params)
{
$sourcePath = $this->getSourcePath($path);
$cachedPath = $this->getCachePath($path, $params);
if ($this->cacheFileExists($path, $params) === true) {
return $cachedPath;
}
if ($this->sourceFileExists($path) === false) {
throw new FileNotFoundException('Could not find the image `' . $sourcePath . '`.');
}
$source = $this->source->read($sourcePath);
if ($source === false) {
throw new FilesystemException('Could not read the image `' . $sourcePath . '`.');
}
// We need to write the image to the local disk before
// doing any manipulations. This is because EXIF data
// can only be read from an actual file.
$tmp = tempnam(sys_get_temp_dir(), 'Glide');
if (file_put_contents($tmp, $source) === false) {
throw new FilesystemException('Unable to write temp file for `' . $sourcePath . '`.');
}
try {
$write = $this->cache->write($cachedPath, $this->api->run($tmp, $this->getAllParams($params)));
if ($write === false) {
throw new FilesystemException('Could not write the image `' . $cachedPath . '`.');
}
} catch (FileExistsException $exception) {
// This edge case occurs when the target already exists
// because it's currently be written to disk in another
// request. It's best to just fail silently.
}
unlink($tmp);
return $cachedPath;
}
示例10: read
/**
* Read session data
* @link http://php.net/manual/en/sessionhandlerinterface.read.php
* @param string $session_id The session id to read data for.
* @return string <p>
* Returns an encoded string of the read data.
* If nothing was read, it must return an empty string.
* Note this value is returned internally to PHP for processing.
* </p>
* @since 5.4.0
*/
public function read($session_id)
{
if ($this->driver->has($path = $this->path . $session_id)) {
return $this->driver->read($path);
}
return '';
}
示例11: read
/**
* Read a file.
*
* @param string $path
* @return string
* @throws IoReadException
*/
public function read($path)
{
if (($ret = $this->fs->read($path)) === false) {
throw new IoReadException("File {$path} could not be read.");
}
return $ret;
}
示例12: read
/**
* Reads settings content of a namespace
*
* @param string $namespace
* @return array
*/
protected function read($namespace)
{
$file = $this->adapter->getFileName($namespace);
if (!$this->fileSystem->has($file)) {
return [];
}
return $this->adapter->onRead($this->fileSystem->read($file));
}
示例13: read
/**
* Read stub file
*
* @param string $content
* @param array $arguments
* @return mixed
*/
protected function read($stub_path)
{
$content = $this->stubbox->read($stub_path);
if ($content === false) {
throw new InvalidArgumentException("File '{$stub_path}' is not found.");
}
return $content;
}
示例14: __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();
}
示例15: getTypes
/**
* Extracts user defined PHP Type's from a source php file.
*
* @param string $package
* @param string $version
* @param string $file
* @return array
*/
private function getTypes($package, $version, $file)
{
$fullPath = $this->vendorDir . '/' . $package . '/' . $version . '/' . $file;
$src = $this->filesystem->read($fullPath);
$ast = $this->parser->parse($src);
$this->traverser->addVisitor($this->typeExtracator);
$this->traverser->traverse($ast);
$this->traverser->removeVisitor($this->typeExtracator);
return $this->typeExtracator->getTypes();
}