protected function copyRecursive($source, $target)
{
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
$this->filesystem->ensureDirectoryExists($target);
foreach ($ri as $file) {
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
$this->filesystem->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
}