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


PHP FilesystemInterface::listContents方法代码示例

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


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

示例1: clean

 /** @inheritdoc */
 public function clean($validPackages)
 {
     foreach (Linq::from($this->filesystem->listContents($this->vendorDir))->where(function ($v) {
         return $v['type'] == 'dir';
     }) as $vendor) {
         if (!Linq::from($validPackages)->any(function ($v, $k) use($vendor) {
             return preg_match('/^' . $vendor['basename'] . '/i', $k);
         })) {
             $this->notify("DELETING: " . $vendor['path'] . "\n");
             $this->filesystem->deleteDir($vendor['path']);
             continue;
         }
         foreach (Linq::from($this->filesystem->listContents($vendor['path']))->where(function ($v) {
             return $v['type'] == 'dir';
         }) as $package) {
             if (!Linq::from($validPackages)->any(function ($v, $k) use($vendor, $package) {
                 return $k == $vendor['basename'] . '/' . $package['basename'];
             })) {
                 $this->notify("DELETING: " . $package['path'] . "\n");
                 $this->filesystem->deleteDir($package['path']);
                 continue;
             }
             foreach (Linq::from($this->filesystem->listContents($package['path']))->where(function ($v) {
                 return $v['type'] == 'dir';
             }) as $version) {
                 if (!Linq::from($validPackages[$vendor['basename'] . '/' . $package['basename']])->any(function ($v) use($version) {
                     return $v == $version['basename'];
                 })) {
                     $this->notify("DELETING: " . $version['path'] . "\n");
                     $this->filesystem->deleteDir($version['path']);
                 }
             }
         }
     }
 }
开发者ID:brad-jones,项目名称:ppm,代码行数:36,代码来源:PackageCleaner.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: getComposerFiles

 /**
  * @return array
  */
 private function getComposerFiles()
 {
     $files = [];
     $fileList = $this->fileSystem->listContents('./', true);
     foreach ($fileList as $file) {
         if ($file['basename'] === self::LOCATE_FILE) {
             $files[] = $file['path'];
         }
     }
     return $files;
 }
开发者ID:dev-nanny,项目名称:connector-base,代码行数:14,代码来源:Locator.php

示例4: handle

 public function handle($term, $extensions = 'jpg,jpeg,gif,png')
 {
     $extensions = explode(",", $extensions);
     $allFiles = $this->filesystem->listContents('', true);
     $files = array();
     foreach ($allFiles as $file) {
         if ($file['type'] == 'file' && ($term == '*' || strpos($file['path'], $term) !== false) && in_array($file['extension'], $extensions)) {
             $files[] = $file['path'];
         }
     }
     return $files;
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:12,代码来源:Search.php

示例5: handle

 /**
  * {@inheritdoc}
  */
 public function handle($config, CertificateResponse $response)
 {
     $remoteAdapter = $this->createAdapter($config);
     $remote = new Filesystem($remoteAdapter);
     $files = $this->master->listContents('.', true);
     foreach ($files as $file) {
         if (0 === strpos($file['basename'], '.')) {
             continue;
         }
         $this->mirror($file['type'], $file['path'], $remote, $remoteAdapter);
     }
 }
开发者ID:acmephp,项目名称:acmephp,代码行数:15,代码来源:AbstractFlysystemAction.php

示例6: listFilesByContainerName

 /**
  * @param string $containerName
  *
  * @return array
  */
 public function listFilesByContainerName($containerName)
 {
     $files = [];
     foreach ($this->filesystem->listContents($containerName, true) as $file) {
         $file['mapped_path'] = sprintf('%s/%s', $this->baseUrl, $file['path']);
         if (array_key_exists('size', $file)) {
             $file['size_human'] = FileSize::convertToHumanReadable($file['size']);
         }
         $files[] = $file;
     }
     return $files;
 }
开发者ID:project-a,项目名称:spryker-file-upload,代码行数:17,代码来源:Storage.php

示例7: yieldFilesInPath

 /**
  * Recursively yield files that meet the specification
  *
  * @param SpecificationInterface $specification
  * @param string $path
  * @return Generator
  */
 private function yieldFilesInPath(SpecificationInterface $specification, $path)
 {
     $listContents = $this->filesystem->listContents($path);
     foreach ($listContents as $location) {
         if ($specification->isSatisfiedBy($location)) {
             (yield $location);
         }
         if ($location['type'] == 'dir') {
             foreach ($this->yieldFilesInPath($specification, $location['path']) as $returnedLocation) {
                 (yield $returnedLocation);
             }
         }
     }
 }
开发者ID:phpdocumentor,项目名称:flyfinder,代码行数:21,代码来源:Finder.php

示例8: _scandir

 /**
  * Return files list in directory
  *
  * @param  string  $path  dir path
  * @return array
  **/
 protected function _scandir($path)
 {
     $paths = array();
     foreach ($this->fs->listContents($path, false) as $object) {
         $paths[] = $object['path'];
     }
     return $paths;
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:14,代码来源:ElFinderVolumeFlysystem.php

示例9: generate

 public function generate($query)
 {
     $files = $this->filesystem->listContents($this->config['directory']);
     array_filter($files, [$this, 'filterFiles']);
     if (empty($files)) {
         throw new RuntimeException('Cannot generate fractal image: template folder is empty');
     }
     mt_srand((double) microtime() * 1000000);
     mt_rand(0, 1);
     $random_file = mt_rand(0, count($files) - 1);
     $resource = imagecreatefromjpeg(DIRECTORY_SEPARATOR . $files[$random_file]['path']);
     if (!is_resource($resource)) {
         throw new RuntimeException('Cannot create image from the fractal template: ' . $files[$random_file]['basename']);
     }
     return $resource;
     // this variant will not work because of the different resource type
     // return $this->filesystem->readStream($files[$random_file]['path']);
 }
开发者ID:kivagant,项目名称:staticus-fractal-manager,代码行数:18,代码来源:GetRandomFileFromDirAdapter.php

示例10: listFiles

 /**
  * @inheritdoc
  */
 public function listFiles($directory = '')
 {
     $files = [];
     foreach ($this->filesystem->listContents($directory, true) as $file) {
         if ($file['type'] == 'dir' || strstr($file['path'], '/.') !== false) {
             continue;
         }
         $files[] = $file['path'];
     }
     return $files;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:14,代码来源:MediaService.php

示例11: getPaths

 protected function getPaths(FilesystemInterface $filesystem, $skipDirs)
 {
     $paths = [];
     foreach ($filesystem->listContents($this->dir, true) as $path) {
         if ($skipDirs && $path['type'] === 'dir') {
             continue;
         }
         $paths[$path['path']] = $path;
     }
     ksort($paths);
     return $paths;
 }
开发者ID:repat,项目名称:flysystem-sync,代码行数:12,代码来源:Sync.php

示例12: 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

示例13: removeEmptyDirectories

 /**
  * {@inheritdoc}
  */
 protected function removeEmptyDirectories($backupName)
 {
     /**
      * @var \SplFileInfo $dir
      */
     foreach ($this->flysystem->listContents($backupName) as $dir) {
         if ($dir['type'] != 'dir') {
             continue;
         }
         if (count($this->flysystem->listContents($dir['path'])) > 0) {
             $this->removeEmptyDirectories($dir['path']);
         } else {
             $this->flysystem->deleteDir($dir['path']);
         }
     }
 }
开发者ID:runopencode,项目名称:backup,代码行数:19,代码来源:FlysystemDestination.php

示例14: eraseDir

 /**
  * Erase a directory.
  *
  * @param string $dirname
  * @throws IoWriteException
  */
 public function eraseDir($dirname = '')
 {
     try {
         $listing = $this->fs->listContents($dirname, false);
         foreach ($listing as $item) {
             if ($item['type'] === 'dir') {
                 $this->fs->deleteDir($item['path']);
             } else {
                 $this->fs->delete($item['path']);
             }
         }
     } catch (Error $ex) {
         throw new IoWriteException("Directory {$dirname} could not be erased.", $ex);
     } catch (Exception $ex) {
         throw new IoWriteException("Directory {$dirname} could not be erased.", $ex);
     }
 }
开发者ID:khelle,项目名称:surume,代码行数:23,代码来源:Filesystem.php

示例15: ensuredEraseDir

 /**
  * Erase a directory.
  *
  * @param string $dirname
  * @throws WriteException
  */
 private function ensuredEraseDir($dirname)
 {
     try {
         $listing = $this->fs->listContents($dirname, false);
         foreach ($listing as $item) {
             if ($item['type'] === 'dir') {
                 $this->fs->deleteDir($item['path']);
             } else {
                 $this->fs->delete($item['path']);
             }
         }
         return;
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     throw new WriteException("Directory {$dirname} could not be erased.", $ex);
 }
开发者ID:kraken-php,项目名称:framework,代码行数:23,代码来源:Filesystem.php


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