本文整理汇总了PHP中League\Flysystem\Filesystem::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::find方法的具体用法?PHP Filesystem::find怎么用?PHP Filesystem::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Filesystem
use Flyfinder\Finder;
use Flyfinder\Path;
use Flyfinder\Specification\IsHidden;
use Flyfinder\Specification\HasExtension;
use Flyfinder\Specification\InPath;
/*
* First create a new Filesystem and add the FlySystem plugin
* In this example we are using a filesystem with the memory adapter
*/
$filesystem = new Filesystem(new Adapter());
$filesystem->addPlugin(new Finder());
// Create some demo files
$filesystem->write('test.txt', 'test');
$filesystem->write('.hiddendir/.test.txt', 'test');
$filesystem->write('.hiddendir/found.txt', 'test');
$filesystem->write('.hiddendir/normaldir/example.txt', 'test');
/*
* In order to tell FlyFinder what to find, you need to give it a specification
* In this example the specification will be satisfied by *.txt files
* within the .hidden directory and its subdirectories that are not hidden
*/
$isHidden = new IsHidden();
$hasExtension = new HasExtension(['txt']);
$inPath = new InPath(new Path('.hiddendir'));
$specification = $inPath->andSpecification($hasExtension)->andSpecification($isHidden->notSpecification());
//FlyFinder will yield a generator object with the files that are found
$generator = $filesystem->find($specification);
$result = [];
foreach ($generator as $value) {
$result[] = $value;
}