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


PHP Filesystem::listContents方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument("file");
     $list = array_filter($this->filesystem->listContents($file, true), function ($file) {
         return isset($file['type']) and ($file['type'] === "file" and isset($file['extension']) and $file['extension'] === "php");
     });
     // If the file argument is not directory, the listContents will return empty array.
     // In this case the user has specified a file
     if (empty($list)) {
         $list = [["path" => $this->filesystem->get($file)->getPath()]];
     }
     $dump = array_map(function ($file) use($output) {
         $output->writeln("Indexing " . $file['path'] . "...");
         return Indexer::index($this->filesystem->get($file['path']));
     }, $list);
     $table = new Table($output);
     $outputs = [];
     foreach ($dump as $a) {
         foreach ($a["functions"] as $val) {
             $outputs[] = [$val['file']->getPath(), $val['function'], implode(", ", array_map(function ($param) {
                 return implode('|', $param['type']) . " " . $param['name'];
             }, $val['arguments'])), implode(", ", $val['return']), (string) $val['scope']];
         }
     }
     $output->writeln("Indexing complete!");
     $output->writeln("Scanned " . count($list) . " files.");
     $output->writeln("Detected " . count($outputs) . " functions.");
     $output->writeln("Rendering Table...");
     $table->setHeaders(['File', 'Function', 'Arguments', 'Return', 'Scope'])->setRows($outputs);
     $table->render();
 }
开发者ID:sekjun9878,项目名称:elphp,代码行数:31,代码来源:ListFunctionsCommand.php

示例2: flush

 /**
  * Flush will flush all cached data.
  */
 public function flush()
 {
     $contents = $this->filesystem->listContents();
     foreach ($contents as $content) {
         $this->filesystem->delete($content['basename']);
     }
 }
开发者ID:isotopsweden,项目名称:wp-cachetop,代码行数:10,代码来源:class-filesystem.php

示例3: listContents

 public function listContents($directory = null)
 {
     $contents = $this->flysystem->listContents($directory);
     $collection = collect();
     foreach ($contents as $object) {
         $collection->push($this->getType($object['type'], $object));
     }
     return $collection;
 }
开发者ID:anavel,项目名称:uploads,代码行数:9,代码来源:Filesystem.php

示例4: getResourcesList

 public function getResourcesList()
 {
     $resourcesToBackup = array();
     $filesystemContents = $this->filesystem->listContents('', true);
     foreach ($filesystemContents as $content) {
         $resourcesToBackup[] = new RemoteResource($content['path'], $content['type']);
     }
     return $resourcesToBackup;
 }
开发者ID:devhelp,项目名称:backup,代码行数:9,代码来源:SourceFlysystemAdapter.php

示例5: posts

 public function posts() : Collection
 {
     return collect($this->filesystem->listContents('posts'))->filter(function (array $item) {
         return $item['type'] === 'dir';
     })->flatMap(function (array $item) {
         return $this->filesystem->listContents($item['path']);
     })->map(function (array $item) {
         $contents = $this->getFile($item['path']);
         return $contents ? Article::create($this->frontMatterParser->parse($contents), url("{$item['dirname']}/{$item['filename']}")) : null;
     })->filter(function ($item) {
         return $item !== null;
     })->sort(function (Article $articleA, Article $articleB) {
         return $articleA->date->getTimeStamp() < $articleB->date->getTimeStamp();
     });
 }
开发者ID:sebastiandedeyne,项目名称:sebastiandedeyne.com,代码行数:15,代码来源:ContentRepository.php

示例6: testListContents

 public function testListContents()
 {
     $list = $this->filesystem->listContents('');
     $this->assertArraySubset([['type' => 'file', 'path' => '2.txt'], ['type' => 'file', 'path' => '3.txt'], ['type' => 'dir', 'path' => 'test']], $list);
     $list = $this->filesystem->listContents('', true);
     $this->assertArraySubset([['type' => 'file', 'path' => '2.txt'], ['type' => 'file', 'path' => '3.txt'], ['type' => 'dir', 'path' => 'test'], ['type' => 'file', 'path' => 'test/1.txt']], $list);
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:7,代码来源:AliyunOssAdapterTest.php

示例7: testDeleteMockResourceExistsSizes

 public function testDeleteMockResourceExistsSizes()
 {
     $resourceDO = $this->getResourceDOMock();
     $this->filesystem->put($resourceDO->getFilePath(), '');
     $resourceDOSize10x11 = $this->getResourceDOMock();
     $resourceDOSize10x11->setWidth(10);
     $resourceDOSize10x11->setHeight(11);
     $this->filesystem->put($resourceDOSize10x11->getFilePath(), '');
     $resourceDOSize20x21 = $this->getResourceDOMock();
     $resourceDOSize20x21->setWidth(20);
     $resourceDOSize20x21->setHeight(21);
     $this->filesystem->put($resourceDOSize20x21->getFilePath(), '');
     $yetAnotherWrongDO = clone $resourceDO;
     $yetAnotherWrongDO->setWidth(998);
     $yetAnotherWrongDO->setHeight(999);
     $this->wrongFiles->create($resourceDO, 'Wrong1');
     $this->wrongFiles->create($resourceDOSize10x11, 'Wrong2');
     $this->wrongFiles->create($resourceDOSize20x21, 'Wrong3');
     $this->wrongFiles->create($yetAnotherWrongDO, 'Wrong4');
     $modelFiles = $this->filesystem->listContents('/', true);
     // Make the expected model looks like filesystem after the command execution
     // With this model we will be sure that other files have not been deleted
     unset($modelFiles[56], $modelFiles[57]);
     $modelFiles[55] = ['type' => 'dir', 'path' => 'testBase/png/def/def/0/c9f/20x21', 'dirname' => 'testBase/png/def/def/0/c9f', 'basename' => '20x21', 'filename' => '20x21'];
     $command = $this->getCommand($resourceDO);
     $result = $command();
     $this->assertTrue($result);
     $this->assertFalse($this->filesystem->has($resourceDOSize10x11->getFilePath()));
     $this->assertFalse($this->filesystem->has($resourceDOSize20x21->getFilePath()));
     $result = $this->filesystem->listContents('/', true);
     $this->assertEquals($modelFiles, $result);
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:32,代码来源:DeleteImageSizesResourceCommandTest.php

示例8: testListContents

 public function testListContents()
 {
     $rawListing = [['path' => 'other_root/file.txt'], ['path' => 'valid/to_deep/file.txt'], ['path' => 'valid/file.txt']];
     $expected = [Util::pathinfo('valid/file.txt')];
     $this->prophecy->listContents('valid', false)->willReturn($rawListing);
     $output = $this->filesystem->listContents('valid', false);
     $this->assertEquals($expected, $output);
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:8,代码来源:FilesystemTests.php

示例9: _scandir

 /**
  * @inheritdoc
  */
 protected function _scandir($path)
 {
     $paths = array();
     foreach ($this->fs->listContents($path, false) as $object) {
         $paths[] = $object['path'];
     }
     return $paths;
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:11,代码来源:FlysystemDriver.php

示例10: file

 public function file()
 {
     $adapter = new Local('app');
     $filesystem = new Filesystem($adapter);
     $contents = $filesystem->listContents();
     echo '<pre>';
     print_r($contents);
     echo '</pre>';
 }
开发者ID:nova-framework,项目名称:sourcefiles-2.2-creating-a-helper,代码行数:9,代码来源:Demo.php

示例11: getItemsToDelete

 /**
  * @return Collection
  */
 private function getItemsToDelete()
 {
     return collect($this->filesystem->listContents("/Api"))->filter(function ($content) {
         if ($content['filename'] === "Endpoint") {
             return false;
         }
         return true;
     });
 }
开发者ID:ValentinGot,项目名称:trakt-api-wrapper,代码行数:12,代码来源:EndpointGenerator.php

示例12: deployToRemote

 /**
  * Deploy files to the remote filesystem.
  *
  * @return void
  */
 public function deployToRemote()
 {
     $local_path = $this->relativeDumpPath();
     $files = $this->localAdapter->listContents($local_path);
     foreach ($files as $file) {
         $contents = $this->localAdapter->readStream($local_path . $file['basename']);
         $file_size = $this->localAdapter->getSize($local_path . $file['basename']);
         $this->out($this->parseString('Uploading %s (%s)', [$file['basename'], $this->formatBytes($file_size)], 'light_green'));
         $this->remoteAdapter->writeStream($local_path . $file['basename'], $contents);
     }
 }
开发者ID:JayBizzle,项目名称:mysqldumper,代码行数:16,代码来源:MySQLDumperCommand.php

示例13: foldersNames

 /**
  * @param string $path
  * @return array
  */
 public function foldersNames($path)
 {
     $files = $this->filesystem->listContents($path);
     $names = [];
     foreach ($files as $file) {
         if ($file['type'] === 'dir') {
             $names[] = $file['filename'];
         }
     }
     return $names;
 }
开发者ID:karion,项目名称:mydrinks,代码行数:15,代码来源:FlySystemAdapter.php

示例14: invalidate

 /**
  * @param string $providerPrefix
  *
  * @return bool
  */
 public function invalidate($providerPrefix)
 {
     $pattern = $this->prefix . strtolower($providerPrefix) . '_';
     $files = $this->filesystem->listContents();
     foreach ($files as $file) {
         if (stripos($file['filename'], $pattern) === 0) {
             $this->filesystem->delete($file['filename']);
         }
     }
     return true;
 }
开发者ID:paul-schulleri,项目名称:adform-client,代码行数:16,代码来源:FileCache.php

示例15: opendir

	/**
	 * {@inheritdoc}
	 */
	public function opendir($path) {
		try {
			$content = $this->flysystem->listContents($this->buildPath($path));
		} catch (FileNotFoundException $e) {
			return false;
		}
		$names = array_map(function ($object) {
			return $object['basename'];
		}, $content);
		return IteratorDirectory::wrap($names);
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:14,代码来源:flysystem.php


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