本文整理汇总了PHP中League\Flysystem\Filesystem::listWith方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::listWith方法的具体用法?PHP Filesystem::listWith怎么用?PHP Filesystem::listWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::listWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @return bool
*/
public function execute()
{
$files = $this->filesystem->listWith(['timestamp'], $this->directoryPath, false);
foreach ($files as $file) {
if ($file['timestamp'] < $this->olderThan->getTimestamp()) {
$this->filesystem->delete($file['path']);
}
}
}
示例2: getPDFFiles
/**
* Get a list of PDF files in the local filesystem at a given relative path.
*
* @param string $path
*
* @return array Array of PDF files
*/
public function getPDFFiles($path)
{
$files = [];
$contents = $this->localFilesystem->listWith(['mimetype', 'path'], $path);
foreach ($contents as $content) {
if ($this->contentIsPdf($content)) {
$files[] = $content;
}
}
// Sort files to keep the order
sort($files);
return $files;
}
示例3:
function it_should_execute_the_delete_old_files_command(Filesystem $filesystem, DateTime $olderThan)
{
$filesystem->listWith(['timestamp'], '/dir', false)->willReturn([['path' => '/dir/file-new.gz', 'timestamp' => 2000], ['path' => '/dir/file-old.gz', 'timestamp' => 1000], ['path' => '/dir/file-older.gz', 'timestamp' => 500]]);
$olderThan->getTimestamp()->willReturn(1500);
$filesystem->delete('/dir/file-older.gz')->shouldBeCalled();
$filesystem->delete('/dir/file-old.gz')->shouldBeCalled();
$this->beConstructedWith($filesystem, '/dir', $olderThan);
$this->execute();
}
示例4: searchFilesWithByPattern
protected function searchFilesWithByPattern(array $keys = [], $pattern, $recursive = false, $is = null)
{
$result = [];
foreach (parent::listWith($keys, '', $recursive) as $data) {
if (isset($is) && $data['type'] !== $is) {
continue;
}
if (preg_match($pattern, $data['path'])) {
$result[] = $data;
}
}
return $result;
}