本文整理汇总了PHP中League\Flysystem\Filesystem::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::read方法的具体用法?PHP Filesystem::read怎么用?PHP Filesystem::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanCreateSmallSitemap
public function testCanCreateSmallSitemap()
{
$expected = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://foo.com/1</loc>
</url>
<url>
<loc>http://foo.com/2</loc>
</url>
<url>
<loc>http://foo.com/3</loc>
</url>
</urlset>
XML;
$urls = [];
for ($i = 1; $i <= 3; $i++) {
$urls[] = ['url' => 'http://foo.com/' . $i];
}
$path = $this->factory->createSitemap(new ArrayIterator($urls));
$actual = $this->filesystem->read($path);
$this->filesystem->delete($path);
$this->assertEquals($expected, $actual);
}
示例2: assets
/**
* Return admin assets
* @param Response $response
* @param $asset
* @return Response|static
* @throws FileNotFoundException
*/
public function assets(Response $response, $asset)
{
$filesystem = new Filesystem(new Adapter(FS2ADMIN));
$expires = 8640000;
try {
// generate cache data
$timestamp_string = gmdate('D, d M Y H:i:s ', $filesystem->getTimestamp($asset)) . 'GMT';
$etag = md5($filesystem->read($asset));
$mime_type = $filesystem->getMimetype($asset);
if (0 !== strpos($mime_type, 'image')) {
$mime_type = 'text/css';
}
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : false;
if (($if_none_match && $if_none_match == "\"{$etag}\"" || !$if_none_match) && ($if_modified_since && $if_modified_since == $timestamp_string)) {
return $response->withStatus('304');
} else {
$response = $response->withHeader('Last-Modified', $timestamp_string)->withHeader('ETag', "\"{$etag}\"");
}
// send out content type, expire time and the file
$response->getBody()->write($filesystem->read($asset));
return $response->withHeader('Expires', gmdate('D, d M Y H:i:s ', time() + $expires) . 'GMT')->withHeader('Content-Type', $mime_type)->withHeader('Pragma', 'cache')->withHeader('Cache-Control', 'cache');
} catch (FileNotFoundException $e) {
throw $e;
}
}
示例3: addData
/**
* Populates the "data" key with the file's JSON data
*
* @param array $file
*/
private function addData(array &$file)
{
$data = json_decode($this->fs->read($file['path']), true);
if ($data === null) {
throw new \DomainException(sprintf('%s is not a valid JSON file.', $file['path']));
}
$file['data'] = $data;
}
示例4: getFile
private function getFile($path)
{
try {
return $this->filesystem->read($path);
} catch (FileNotFoundException $e) {
return null;
}
}
示例5: get
/**
* Returns the value for a key.
*
* @param string $key A unique key
*
* @return string|false The file contents or false on failure.
*/
public function get($key)
{
try {
return $this->filesystem->read($key);
} catch (FileNotFoundException $exception) {
return false;
}
}
示例6: read
/**
* @inheritdoc
*/
public function read($path)
{
try {
return $this->fileSystem->read($this->getInnerPath($path));
} catch (FileNotFoundException $e) {
throw $this->exceptionWrapper($e, $path);
}
}
示例7: parse
/**
* {@inheritdoc}
*/
public function parse(Configuration $configuration = null)
{
if (!$this->filesystem->has($this->file)) {
throw new ParsingFailed(sprintf('File "%s" not found', $this->file));
}
$fileContents = $this->filesystem->read($this->file);
$parser = new Text($fileContents);
return $parser->parse($configuration);
}
示例8: loadFile
/**
* @return false|string
*/
private function loadFile()
{
if (!$this->filesystem->has($this->getFile())) {
$this->filesystem->write($this->getFile(), '');
}
if (!$this->sites) {
$this->sites = $this->filesystem->read($this->file);
}
return $this->sites;
}
示例9: fetch
/**
* @inheritdoc
*/
public function fetch($key)
{
if ($this->filesystem->has($key)) {
// The file exist, read it!
$data = @unserialize($this->filesystem->read($key));
if ($data instanceof CacheEntry) {
return $data;
}
}
return;
}
示例10: get
/**
* @param string $providerPrefix
* @param string $uri
* @param string $query
*
* @return bool|mixed
*/
public function get($providerPrefix, $uri, $query)
{
$hash = $this->getHash($providerPrefix, $uri, $query);
$ttlCutoff = time() - $this->ttl;
if ($this->filesystem->has($hash) and $this->filesystem->getTimestamp($hash) > $ttlCutoff) {
$data = $this->filesystem->read($hash);
if (!empty($data)) {
return $data;
}
}
return false;
}
示例11: getData
/**
* Returns the historical price data as a csv string for $ticker
* @param string $ticker
* @param bool $fromCache
* @param bool $saveToCache
* @param bool $return
* @return TickerCollection
*/
public function getData($ticker, $fromCache = true, $saveToCache = true, $return = true)
{
if ($fromCache && $this->fileSystem->has($ticker)) {
return $this->present($ticker, $this->fileSystem->read($ticker));
}
$data = (string) $this->guzzle->request('GET', '', ['query' => ['s' => $ticker, 'ignore' => '.csv']])->getBody();
if ($saveToCache) {
$this->fileSystem->put($ticker, $data);
}
if ($return) {
return $this->present($ticker, $data);
}
}
示例12: testPrefixes
/**
* Test setting prefixes for both output filename and URLs in vtt file
*/
public function testPrefixes()
{
$ts = new ThumbnailSprite();
$ts->setSource($this->testSrc);
$ts->setOutputDirectory(dirname($this->testSrc));
$ts->setPrefix('blubber');
$ts->setUrlPrefix('http://example.org');
$ts->generate();
$this->assertTrue($this->outputFS->has('blubber.jpg'));
$this->assertTrue($this->outputFS->has('blubber.vtt'));
$vtt = $this->outputFS->read('blubber.vtt');
$this->assertContains('http://example.org/blubber.jpg#xywh', $vtt);
}
示例13: load
/**
* {@inheritdoc}
*/
public function load(Configuration $configuration = null)
{
if (!$this->filesystem->has($this->file)) {
throw new LoaderException(sprintf('File "%s" not found', $this->file));
}
if (!($fileContents = $this->filesystem->read($this->file))) {
throw new LoaderException(sprintf('Reading file "%s" failed', $this->file));
}
try {
$ini = $this->getParser()->parse($fileContents);
} catch (ParserException $e) {
throw new LoaderException('Cannot parse INI', 0, $e);
}
return $this->parseSections($ini, $configuration);
}
示例14: readModuleMetadata
/**
* read all metadata from module file.
* @param type $module_system_name
* @return type
*/
public function readModuleMetadata($module_system_name)
{
$adapter = new Local(MODULE_PATH);
$filesystem = new Filesystem($adapter);
unset($adapter);
$output = [];
if ($filesystem->has($module_system_name . DS . $module_system_name . '.php')) {
$content = $filesystem->read($module_system_name . DS . $module_system_name . '.php');
preg_match_all('|([a-zA-Z0-9-_ ]+):(.*)$|mi', $content, $matches, PREG_PATTERN_ORDER);
unset($content);
if (isset($matches) && is_array($matches) && array_key_exists(1, $matches) && array_key_exists(2, $matches) && is_array($matches[1]) && is_array($matches[2])) {
foreach ($matches[1] as $key => $item) {
if (!is_array($item) && array_key_exists($key, $matches[2]) && !is_array($matches[2][$key])) {
$output[trim($item)] = trim($matches[2][$key]);
}
}
}
}
// validate available metadata
foreach ($this->available_metadata as $meta_name) {
if (!array_key_exists($meta_name, $output)) {
$output[$meta_name] = '';
}
}
unset($filesystem, $item, $key, $matches, $meta_name);
return $output;
}
示例15: readThemeMetadata
/**
* read all metadata from theme file.
* @param type $theme_system_name
* @return type
*/
public function readThemeMetadata($theme_system_name)
{
// get theme config
$Config = new \System\Libraries\Config();
$Config->load('theme');
$theme_dir = $Config->get('theme_dir', 'theme');
unset($Config);
$adapter = new Local($theme_dir);
$filesystem = new Filesystem($adapter);
unset($adapter, $theme_dir);
$output = [];
if ($filesystem->has($theme_system_name . DS . $theme_system_name . '.php')) {
$content = $filesystem->read($theme_system_name . DS . $theme_system_name . '.php');
preg_match_all('|([a-zA-Z0-9-_ ]+):(.*)$|mi', $content, $matches, PREG_PATTERN_ORDER);
unset($content);
if (isset($matches) && is_array($matches) && array_key_exists(1, $matches) && array_key_exists(2, $matches) && is_array($matches[1]) && is_array($matches[2])) {
foreach ($matches[1] as $key => $item) {
if (!is_array($item) && array_key_exists($key, $matches[2]) && !is_array($matches[2][$key])) {
$output[trim($item)] = trim($matches[2][$key]);
}
}
}
}
// validate available metadata
foreach ($this->available_metadata as $meta_name) {
if (!array_key_exists($meta_name, $output)) {
$output[$meta_name] = '';
}
}
unset($filesystem, $item, $key, $matches, $meta_name);
return $output;
}