本文整理汇总了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;
}
示例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');
}
示例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;
}