当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::read方法代码示例

本文整理汇总了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);
    }
开发者ID:antoniorequenalorente,项目名称:web_starter_kit,代码行数:26,代码来源:SitemapFactoryTest.php

示例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;
     }
 }
开发者ID:frogsystem,项目名称:legacy-bridge,代码行数:33,代码来源:AdminController.php

示例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;
 }
开发者ID:rieschl,项目名称:techtalks_data,代码行数:13,代码来源:AbstractLoader.php

示例4: getFile

 private function getFile($path)
 {
     try {
         return $this->filesystem->read($path);
     } catch (FileNotFoundException $e) {
         return null;
     }
 }
开发者ID:sebastiandedeyne,项目名称:sebastiandedeyne.com,代码行数:8,代码来源:ContentRepository.php

示例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;
     }
 }
开发者ID:svycka,项目名称:sv-images,代码行数:15,代码来源:FlySystemStorage.php

示例6: read

 /**
  * @inheritdoc
  */
 public function read($path)
 {
     try {
         return $this->fileSystem->read($this->getInnerPath($path));
     } catch (FileNotFoundException $e) {
         throw $this->exceptionWrapper($e, $path);
     }
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:11,代码来源:FileSystem.php

示例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);
 }
开发者ID:indigophp,项目名称:supervisor-configuration,代码行数:12,代码来源:Filesystem.php

示例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;
 }
开发者ID:bramdevries,项目名称:forge-cli,代码行数:13,代码来源:FileLoader.php

示例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;
 }
开发者ID:thedeedawg,项目名称:guzzle-cache-middleware,代码行数:14,代码来源:FlysystemStorage.php

示例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;
 }
开发者ID:paul-schulleri,项目名称:adform-client,代码行数:19,代码来源:FileCache.php

示例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);
     }
 }
开发者ID:parthpatel1001,项目名称:analyzer,代码行数:21,代码来源:YahooFinance.php

示例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);
 }
开发者ID:emgag,项目名称:video-thumbnail-sprite,代码行数:16,代码来源:ThumbnailSpriteTest.php

示例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);
 }
开发者ID:supervisorphp,项目名称:configuration,代码行数:18,代码来源:IniFileLoader.php

示例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;
 }
开发者ID:AgniCMS,项目名称:agni-framework,代码行数:32,代码来源:Metadata.php

示例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;
 }
开发者ID:AgniCMS,项目名称:agni-framework,代码行数:37,代码来源:Metadata.php


注:本文中的League\Flysystem\Filesystem::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。