public function downloadFolder($path, $to = null)
{
$fs = $this->getAdapter($path);
$files = $fs->getFiles($this->normalizePath($path));
$to = $to ?: $this->createTempFolder('', false);
if (is_array($files)) {
foreach ($files as $file) {
if ('file' === $file['type']) {
$content = $fs->read($this->normalizePath($path . '/' . $file['name']));
$this->cacheFilesystem->write($to . '/' . $file['name'], $content);
} else {
$this->downloadFolder($path . '/' . $file['name'], $to . '/' . $file['name']);
}
}
}
return $to;
}