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


PHP FilesystemInterface::getAdapter方法代码示例

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


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

示例1: adapterType

 protected function adapterType()
 {
     if ($this->filesystem instanceof Filesystem) {
         $reflect = new \ReflectionClass($this->filesystem->getAdapter());
         return $reflect->getShortName();
     }
     return 'Unknown';
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:8,代码来源:AdapterPlugin.php

示例2: handle

 public function handle($path)
 {
     $files = [];
     $folders = [];
     $list = $this->filesystem->listContents($path);
     $ignored = ['.', '..', '.DS_Store', '.gitignore', '.htaccess'];
     foreach ($list as $entry) {
         if (in_array($entry['basename'], $ignored)) {
             continue;
         }
         if (!$this->filesystem->authorized($entry['path'])) {
             continue;
         }
         if ($entry['type'] === 'file') {
             try {
                 $url = $this->filesystem->url($entry['path']);
             } catch (\Exception $e) {
                 $url = $entry['path'];
             }
             // Ugh, for some reason the foldername for the theme is included twice. Why?
             // For now we 'fix' this with an ugly hack, replacing it. :-/
             // TODO: dig into Filesystem and figure out why this happens.
             $pathsegments = explode('/', $entry['path']);
             if (!empty($pathsegments[0])) {
                 $url = str_replace('/' . $pathsegments[0] . '/' . $pathsegments[0] . '/', '/' . $pathsegments[0] . '/', $url);
             }
             $files[$entry['path']] = ['path' => $entry['dirname'], 'filename' => $entry['basename'], 'newpath' => $entry['path'], 'relativepath' => $entry['path'], 'writable' => true, 'readable' => false, 'type' => isset($entry['extension']) ? $entry['extension'] : '', 'filesize' => Lib::formatFilesize($entry['size']), 'modified' => date("Y/m/d H:i:s", $entry['timestamp']), 'permissions' => 'public', 'url' => $url];
             /* **** Extra checks for files that can be resolved via PHP urlopen functions **** */
             try {
                 $files[$entry['path']]['permissions'] = $this->filesystem->getVisibility($entry['path']);
             } catch (\Exception $e) {
                 // Computer says "No!"
             }
             $fullfilename = $this->filesystem->getAdapter()->applyPathPrefix($entry['path']);
             if (is_readable($fullfilename)) {
                 $files[$entry['path']]['readable'] = true;
                 if (!empty($entry['extension']) && in_array($entry['extension'], ['gif', 'jpg', 'png', 'jpeg'])) {
                     $size = getimagesize($fullfilename);
                     $files[$entry['path']]['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
                 }
                 $files[$entry['path']]['permissions'] = util::full_permissions($fullfilename);
             }
         }
         if ($entry['type'] == 'dir') {
             $folders[$entry['path']] = ['path' => $entry['dirname'], 'foldername' => $entry['basename'], 'newpath' => $entry['path'], 'modified' => date("Y/m/d H:i:s", $entry['timestamp']), 'writable' => true];
             $fullfilename = $this->filesystem->getAdapter()->applyPathPrefix($entry['path']);
             /* **** Extra checks for files that can be resolved via PHP urlopen functions **** */
             if (is_readable($fullfilename)) {
                 if (!is_writable($fullfilename)) {
                     $folders[$entry['path']]['writable'] = false;
                 }
             }
         }
     }
     ksort($files);
     ksort($folders);
     return [$files, $folders];
 }
开发者ID:Twiebie,项目名称:bolt,代码行数:58,代码来源:Browse.php

示例3: getAdapter

 /**
  * @return AdapterInterface
  */
 public function getAdapter()
 {
     if (!method_exists($this->fileSystem, 'getAdapter')) {
         throw new InvalidArgumentException("This wrapper requires the getAdapter method to exist on the fileSystem");
     }
     return $this->fileSystem->getAdapter();
 }
开发者ID:graze,项目名称:data-file,代码行数:10,代码来源:FilesystemWrapper.php

示例4: getIcon

 /**
  * Find the icon based on the used Adapter
  *
  * @return string
  */
 protected function getIcon()
 {
     try {
         $adapter = $this->fs->getAdapter();
     } catch (\Exception $e) {
         $adapter = null;
     }
     if ($adapter instanceof League\Flysystem\Adapter\AbstractFtpAdapter) {
         $icon = 'volume_icon_ftp.png';
     } elseif ($adapter instanceof League\Flysystem\Dropbox\DropboxAdapter) {
         $icon = 'volume_icon_dropbox.png';
     } else {
         $icon = 'volume_icon_local.png';
     }
     $parentUrl = defined('ELFINDER_IMG_PARENT_URL') ? rtrim(ELFINDER_IMG_PARENT_URL, '/') . '/' : '';
     return $parentUrl . 'img/' . $icon;
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:22,代码来源:ElFinderVolumeFlysystem.php

示例5: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch(FilesystemInterface $filesystem, $fileKey)
 {
     if (!$filesystem->has($fileKey)) {
         throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $fileKey));
     }
     if (false === ($stream = $filesystem->readStream($fileKey))) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     if (!$this->tmpFilesystem->has(dirname($fileKey))) {
         $this->tmpFilesystem->createDir(dirname($fileKey));
     }
     $localPathname = $this->tmpFilesystem->getAdapter()->getPathPrefix() . $fileKey;
     if (false === file_put_contents($localPathname, $stream)) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     return new \SplFileInfo($localPathname);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:20,代码来源:FileFetcher.php

示例6: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch(FilesystemInterface $filesystem, $fileKey, array $options = [])
 {
     if (!$filesystem->has($fileKey)) {
         throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $fileKey));
     }
     if (false === ($stream = $filesystem->readStream($fileKey))) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     if (!$this->tmpFilesystem->has(dirname($fileKey))) {
         $this->tmpFilesystem->createDir(dirname($fileKey));
     }
     // TODO: we should not get the path prefix like that
     // TODO: it should be injected in the constructor
     $localPathname = $this->tmpFilesystem->getAdapter()->getPathPrefix() . $fileKey;
     if (false === file_put_contents($localPathname, $stream)) {
         throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
     }
     return new \SplFileInfo($localPathname);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:22,代码来源:FileFetcher.php

示例7: onGetClassGenerateFile

 /**
  * Use flysystem to save the file in the desired location.
  *
  * @param \Onema\ClassyFile\Event\GetClassEvent $event
  */
 public function onGetClassGenerateFile(GetClassEvent $event)
 {
     $statement = $event->getStatements();
     $fileLocation = $event->getFileLocation();
     $code = $event->getCode();
     $name = $statement->name;
     if (!$this->filesystem->has($fileLocation)) {
         // dir doesn't exist, make it
         $this->filesystem->createDir($fileLocation);
     }
     $location = sprintf('%s/%s.php', $fileLocation, $name);
     $this->filesystem->put($location, $code);
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof AbstractAdapter) {
         $prefix = $adapter->getPathPrefix();
         $location = Util::normalizePath($location);
         $event->setFileLocation(sprintf('%s%s', $prefix, $location));
     }
 }
开发者ID:onema,项目名称:classyfile,代码行数:24,代码来源:GenerateClassFile.php

示例8: url

 /**
  * Get the URL for the file at the given path.
  *
  * @param  string  $path
  * @return string
  */
 public function url($path)
 {
     $adapter = $this->driver->getAdapter();
     if ($adapter instanceof AwsS3Adapter) {
         return $adapter->getClient()->getObjectUrl($adapter->getBucket(), $path);
     } elseif ($adapter instanceof LocalAdapter) {
         return '/storage/' . $path;
     } else {
         throw new RuntimeException('This driver does not support retrieving URLs.');
     }
 }
开发者ID:ziracmo,项目名称:Projet-transversal-2,代码行数:17,代码来源:FilesystemAdapter.php

示例9: extract

 /** @inheritdoc */
 public function extract($zipBallPath, $to)
 {
     $absolutePathToZipBall = $this->filesystem->getAdapter()->applyPathPrefix($zipBallPath);
     if ($this->zip->open($absolutePathToZipBall) === true) {
         $absolutePathToExtract = $this->filesystem->getAdapter()->applyPathPrefix($to);
         $this->zip->extractTo($absolutePathToExtract);
         $this->zip->close();
         $zipCreatedFolder = Linq::from($this->filesystem->listContents($to))->single(function ($object) {
             return $object['type'] == 'dir';
         })['path'];
         foreach ($this->filesystem->listContents($zipCreatedFolder, true) as $object) {
             if ($object['type'] == "file") {
                 $segments = explode('/', $object['path']);
                 unset($segments[4]);
                 $this->filesystem->rename($object['path'], implode('/', $segments));
             }
         }
         $this->filesystem->deleteDir($zipCreatedFolder);
         return;
     }
     throw new ZipExtractionFailed($zipBall, $to);
 }
开发者ID:brad-jones,项目名称:ppm,代码行数:23,代码来源:ZipExtractor.php

示例10: url

 /**
  * Get the URL for the file at the given path.
  *
  * @param  string  $path
  * @return string
  */
 public function url($path)
 {
     $adapter = $this->driver->getAdapter();
     if ($adapter instanceof AwsS3Adapter) {
         $path = $adapter->getPathPrefix() . $path;
         return $adapter->getClient()->getObjectUrl($adapter->getBucket(), $path);
     } elseif ($adapter instanceof LocalAdapter) {
         $path = '/storage/' . $path;
         return Str::contains($path, '/storage/public') ? Str::replaceFirst('/public', '', $path) : $path;
     } elseif (method_exists($adapter, 'getUrl')) {
         return $adapter->getUrl($path);
     } else {
         throw new RuntimeException('This driver does not support retrieving URLs.');
     }
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:21,代码来源:FilesystemAdapter.php

示例11: readFile

 /**
  * Given the path to a composer file we return it's json as an array.
  *
  * @param  string $file
  * @return array
  */
 private function readFile($file)
 {
     $this->cache->setNamespace(sha1(__CLASS__));
     $item = $this->cache->getItem(sha1($file));
     $data = $item->get();
     if ($item->isMiss()) {
         $item->lock();
         if ($this->filesystem->has($file)) {
             $data = json_decode($this->filesystem->read($file), true);
         } else {
             throw new ComposerFileNotFound($this->filesystem->getAdapter()->applyPathPrefix($file));
         }
         $this->cache->save($item->set($data));
     }
     return $data;
 }
开发者ID:brad-jones,项目名称:ppm,代码行数:22,代码来源:ComposerFileReader.php

示例12: init

 /**
  * Prepare driver before mount volume.
  * Return true if volume is ready.
  *
  * @return bool
  **/
 protected function init()
 {
     $this->fs = $this->options['filesystem'];
     if (!$this->fs instanceof FilesystemInterface) {
         return $this->setError('A filesystem instance is required');
     }
     if ($this->fs instanceof Filesystem) {
         $adapter = $this->fs->getAdapter();
         // If the Flysystem adapter already is a cache, try to determine the cache.
         if ($adapter instanceof CachedAdapter) {
             // Try to get the cache (method doesn't exist in all versions)
             if (method_exists($adapter, 'getCache')) {
                 $this->fscache = $adapter->getCache();
             } elseif ($this->options['fscache'] instanceof CacheInterface) {
                 $this->fscache = $this->options['fscache'];
             }
         } elseif ($this->options['cache']) {
             switch ($this->options['cache']) {
                 case 'session':
                     $this->fscache = new SessionStore($this->session, 'fls_cache_' . $this->id);
                     break;
                 case 'memory':
                     $this->fscache = new MemoryStore();
                     break;
             }
             if ($this->fscache) {
                 $adapter = new CachedAdapter($adapter, $this->fscache);
                 $this->fs = new Filesystem($adapter);
             }
         }
     }
     $this->fs->addPlugin(new GetUrl());
     $this->options['icon'] = $this->options['icon'] ?: (empty($this->options['rootCssClass']) ? $this->getIcon() : '');
     $this->root = $this->options['path'];
     if ($this->options['glideURL']) {
         $this->urlBuilder = UrlBuilderFactory::create($this->options['glideURL'], $this->options['glideKey']);
     }
     if ($this->options['imageManager']) {
         $this->imageManager = $this->options['imageManager'];
     } else {
         $this->imageManager = new ImageManager();
     }
     return true;
 }
开发者ID:barryvdh,项目名称:elfinder-flysystem-driver,代码行数:50,代码来源:Driver.php

示例13: setFilesystem

 public function setFilesystem(FilesystemInterface $filesystem)
 {
     $this->adapter = $filesystem->getAdapter();
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:4,代码来源:FlysystemUrlPlugin.php


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