本文整理汇总了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();
}
示例2: flush
/**
* Flush will flush all cached data.
*/
public function flush()
{
$contents = $this->filesystem->listContents();
foreach ($contents as $content) {
$this->filesystem->delete($content['basename']);
}
}
示例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;
}
示例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;
}
示例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();
});
}
示例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);
}
示例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);
}
示例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);
}
示例9: _scandir
/**
* @inheritdoc
*/
protected function _scandir($path)
{
$paths = array();
foreach ($this->fs->listContents($path, false) as $object) {
$paths[] = $object['path'];
}
return $paths;
}
示例10: file
public function file()
{
$adapter = new Local('app');
$filesystem = new Filesystem($adapter);
$contents = $filesystem->listContents();
echo '<pre>';
print_r($contents);
echo '</pre>';
}
示例11: getItemsToDelete
/**
* @return Collection
*/
private function getItemsToDelete()
{
return collect($this->filesystem->listContents("/Api"))->filter(function ($content) {
if ($content['filename'] === "Endpoint") {
return false;
}
return true;
});
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}