本文整理汇总了PHP中League\Flysystem\Filesystem::hash方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::hash方法的具体用法?PHP Filesystem::hash怎么用?PHP Filesystem::hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::hash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore
/**
* {@inheritdoc}
*
* @throws FileExistsException
* @throws \InvalidArgumentException
* @throws FileNotFoundException
* @throws LogicException
*/
public function restore(Filesystem $source, Filesystem $destination, ReadonlyDatabase $database, array $parameter)
{
// TODO make it smoother
$files = $source->listFiles('', true);
$progressBar = new ProgressBar($this->output, count($files));
$progressBar->setOverwrite(true);
$progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
$progressBar->start();
foreach ($files as $file) {
$path = $file['path'];
$fullPath = $parameter['directory'] . '/' . $file['path'];
if ($destination->has($fullPath)) {
if ($destination->hash($fullPath) === $source->hash($path)) {
$progressBar->advance();
continue;
}
$destination->delete($fullPath);
}
$destination->writeStream($fullPath, $source->readStream($path));
$progressBar->advance();
}
$progressBar->finish();
}