diff --git a/system/src/Grav/Console/SetupCommand.php b/system/src/Grav/Console/SetupCommand.php
index 9ca38dc47..7e7ab3a51 100644
--- a/system/src/Grav/Console/SetupCommand.php
+++ b/system/src/Grav/Console/SetupCommand.php
@@ -150,8 +150,13 @@ EOT
$to = $this->destination . $target;
$output->writeln(' ' . $source . ' -> ' . $to);
- @unlink ($to);
- symlink ($from, $to);
+
+ if (is_dir($to)) {
+ $this->rmdir($to);
+ } else {
+ @unlink($to);
+ }
+ symlink($from, $to);
}
}
@@ -271,4 +276,21 @@ EOT
}
}
}
+
+ private function rmdir($dir) {
+ $files = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+
+ foreach ($files as $fileinfo) {
+ if ($fileinfo->isDir()) {
+ if (false === rmdir($fileinfo->getRealPath())) return false;
+ } else {
+ if (false === unlink($fileinfo->getRealPath())) return false;
+ }
+ }
+
+ return rmdir($dir);
+ }
}