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


PHP Config::filesystems方法代码示例

本文整理汇总了PHP中app\Config::filesystems方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::filesystems方法的具体用法?PHP Config::filesystems怎么用?PHP Config::filesystems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Config的用法示例。


在下文中一共展示了Config::filesystems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFilesystem

 /**
  * Get the filesystem manager.
  *
  * @return MountManager
  * @throws \Exception
  */
 public static function getFilesystem()
 {
     $config = new Config();
     $manager = new MountManager();
     foreach ($config->filesystems() as $name => $fsConfig) {
         $adapterName = '\\League\\Flysystem\\Adapter\\' . self::camelcase($fsConfig['type']);
         $adapter = new $adapterName($fsConfig['root']);
         $fs = new Filesystem($adapter);
         $manager->mountFilesystem($name, $fs);
     }
     return $manager;
 }
开发者ID:samwilson,项目名称:swidau,代码行数:18,代码来源:App.php

示例2: testLocalCacheFile

 public function testLocalCacheFile()
 {
     $config = new Config();
     $this->assertArrayHasKey('cache', $config->filesystems());
     $item = new Item(null, $this->testUser);
     $item->save([], null, null, 'Test file contents.');
     $this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . '1_v1_o', $item->getCachePath());
     $this->assertFileExists(__DIR__ . '/data/cache/1_v1_o');
 }
开发者ID:samwilson,项目名称:swidau,代码行数:9,代码来源:ItemTest.php

示例3: getCachePath

 /**
  * Get a local filesystem path to the requested file, creating it if required.
  * @param string $format The file format, one of 'o', 'd', or 't'.
  * @param int $version The version of the file to fetch.
  * @return string The fully-qualified path to the file.
  * @throws \Exception
  */
 public function getCachePath($format = 'o', $version = null)
 {
     if (is_null($version)) {
         $version = $this->getVersionCount();
     }
     if ($version > $this->getVersionCount()) {
         throw new Exception("Version {$version} does not exist for Item " . $this->getId());
     }
     $filesystem = App::getFilesystem();
     $path = $this->getFilePath($version);
     // Get local filesystem root.
     $config = new Config();
     $filesystems = $config->filesystems();
     $root = realpath($filesystems['cache']['root']);
     // First of all copy the original file to the cache.
     $filenameOrig = $this->getId() . '_v' . $version . '_o';
     if (!$filesystem->has("cache://" . $filenameOrig)) {
         $filesystem->copy("storage://{$path}", "cache://" . $filenameOrig);
     }
     $pathnameOrig = $root . DIRECTORY_SEPARATOR . $filenameOrig;
     if ($format === 'o') {
         return $pathnameOrig;
     }
     // Then create smaller version if required.
     $filenameDisplay = $this->getId() . '_v' . $version . '_t';
     $pathnameDisplay = $root . DIRECTORY_SEPARATOR . $filenameDisplay;
     $manager = new ImageManager();
     $image = $manager->make($pathnameOrig);
     if ($format === 'd') {
         // 'Display' size.
         $width = $image->getWidth();
         $height = $image->getHeight();
         $newWidth = $width > $height ? 700 : null;
         $newHeight = $width > $height ? null : 700;
         $image->resize($newWidth, $newHeight, function (Constraint $constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     } else {
         // Thumbnail.
         $image->fit(200);
     }
     $image->save($pathnameDisplay);
     clearstatcache(false, $pathnameDisplay);
     return $pathnameDisplay;
 }
开发者ID:samwilson,项目名称:swidau,代码行数:53,代码来源:Item.php


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