|
|
@@ -7,6 +7,7 @@ use Illuminate\Filesystem\Filesystem;
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
use Illuminate\Support\Str;
|
|
|
use League\Flysystem\Adapter\Local as LocalAdapter;
|
|
|
+use League\Flysystem\Local\LocalFilesystemAdapter;
|
|
|
use League\Flysystem\Filesystem as Flysystem;
|
|
|
use League\Flysystem\MountManager;
|
|
|
|
|
|
@@ -145,16 +146,30 @@ class PublishCommand extends Command
|
|
|
|
|
|
protected function publishDirectory($from, $to)
|
|
|
{
|
|
|
+ $localClass = class_exists(LocalAdapter::class) ? LocalAdapter::class : LocalFilesystemAdapter::class;
|
|
|
+
|
|
|
$this->moveManagedFiles(new MountManager([
|
|
|
- 'from' => new Flysystem(new LocalAdapter($from)),
|
|
|
- 'to' => new Flysystem(new LocalAdapter($to)),
|
|
|
+ 'from' => new Flysystem(new $localClass($from)),
|
|
|
+ 'to' => new Flysystem(new $localClass($to)),
|
|
|
]));
|
|
|
|
|
|
$this->status($from, $to, 'Directory');
|
|
|
}
|
|
|
|
|
|
- protected function moveManagedFiles($manager)
|
|
|
+ protected function moveManagedFiles(MountManager $manager)
|
|
|
{
|
|
|
+ if (method_exists($manager, 'write')) {
|
|
|
+ foreach ($manager->listContents('from://', true) as $file) {
|
|
|
+ $path = Str::after($file['path'], 'from://');
|
|
|
+
|
|
|
+ if ($file['type'] === 'file' && (! $manager->fileExists('to://'.$path) || $this->option('force'))) {
|
|
|
+ $manager->write('to://'.$path, $manager->read($file['path']));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
foreach ($manager->listContents('from://', true) as $file) {
|
|
|
if (
|
|
|
$file['type'] === 'file'
|