diff --git a/backend/Services/Storage/Filesystem.php b/backend/Services/Storage/Filesystem.php index aa6526b..a748206 100644 --- a/backend/Services/Storage/Filesystem.php +++ b/backend/Services/Storage/Filesystem.php @@ -26,7 +26,7 @@ class Filesystem implements Service $this->separator = $config['separator']; $this->path_prefix = $this->separator; - $adapter = $config['adapters'][$config['filesystem_adapter']]; + $adapter = $config['adapter']; $config = isset($config['config']) ? $config['config'] : []; $this->storage = new Flysystem($adapter(), $config); diff --git a/configuration_sample.php b/configuration_sample.php index 96104e3..6e317a2 100644 --- a/configuration_sample.php +++ b/configuration_sample.php @@ -75,14 +75,11 @@ return [ 'config' => [ 'separator' => '/', 'config' => [], - 'filesystem_adapter' => 'localfilesystem', - 'adapters' => [ - 'localfilesystem' => function () { - return new \League\Flysystem\Adapter\Local( - __DIR__.'/repository' - ); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Adapter\Local( + __DIR__.'/repository' + ); + }, ], ], 'Filegator\Services\Archiver\ArchiverInterface' => [ diff --git a/docs/configuration/storage.md b/docs/configuration/storage.md index b89541b..deaa6b3 100644 --- a/docs/configuration/storage.md +++ b/docs/configuration/storage.md @@ -14,14 +14,11 @@ With default adapter you just need to configure where your ```repository``` fold 'config' => [ 'separator' => '/', 'config' => [], - 'filesystem_adapter' => 'localfilesystem', - 'adapters' => [ - 'localfilesystem' => function () { - return new \League\Flysystem\Adapter\Local( - __DIR__.'/repository' - ); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Adapter\Local( + __DIR__.'/repository' + ); + }, ], ], @@ -36,18 +33,15 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/ftp 'config' => [ 'separator' => '/', 'config' => [], - 'filesystem_adapter' => 'ftp', - 'adapters' => [ - 'ftp' => function () { - return new \League\Flysystem\Adapter\Ftp([ - 'host' => 'example.com', - 'username' => 'demo', - 'password' => 'password', - 'port' => 21, - 'timeout' => 10, - ]); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Adapter\Ftp([ + 'host' => 'example.com', + 'username' => 'demo', + 'password' => 'password', + 'port' => 21, + 'timeout' => 10, + ]); + }, ], ], @@ -64,18 +58,15 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/sft 'config' => [ 'separator' => '/', 'config' => [], - 'filesystem_adapter' => 'sftp', - 'adapters' => [ - 'sftp' => function () { - return new \League\Flysystem\Sftp\SftpAdapter([ - 'host' => 'example.com', - 'port' => 22, - 'username' => 'demo', - 'password' => 'password', - 'timeout' => 10, - ]); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Sftp\SftpAdapter([ + 'host' => 'example.com', + 'port' => 22, + 'username' => 'demo', + 'password' => 'password', + 'timeout' => 10, + ]); + }, ], ], @@ -90,16 +81,15 @@ See official [documentation](https://flysystem.thephpleague.com/docs/adapter/dro 'handler' => '\Filegator\Services\Storage\Filesystem', 'config' => [ 'separator' => '/', - 'config' => [], - 'filesystem_adapter' => 'dropbox', - 'adapters' => [ - 'dropbox' => function () { - $authorizationToken = '1234'; - $client = new \Spatie\Dropbox\Client($authorizationToken); - - return new \Spatie\FlysystemDropbox\DropboxAdapter($client); - }, + 'config' => [ + 'case_sensitive' => false, ], + 'adapter' => function () { + $authorizationToken = '1234'; + $client = new \Spatie\Dropbox\Client($authorizationToken); + + return new \Spatie\FlysystemDropbox\DropboxAdapter($client); + }, ], ], diff --git a/tests/backend/Unit/ArchiverTest.php b/tests/backend/Unit/ArchiverTest.php index 874ef82..18ffc32 100644 --- a/tests/backend/Unit/ArchiverTest.php +++ b/tests/backend/Unit/ArchiverTest.php @@ -41,12 +41,9 @@ class ArchiverTest extends TestCase $storage = new Filesystem(); $storage->init([ 'separator' => '/', - 'filesystem_adapter' => 'nulladapter', - 'adapters' => [ - 'nulladapter' => function () { - return new \League\Flysystem\Adapter\NullAdapter(); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Adapter\NullAdapter(); + }, ]); $uniqid = $this->archiver->createArchive($storage); @@ -60,12 +57,9 @@ class ArchiverTest extends TestCase $storage = new Filesystem(); $storage->init([ 'separator' => '/', - 'filesystem_adapter' => 'memoryadapter', - 'adapters' => [ - 'memoryadapter' => function () { - return new \League\Flysystem\Memory\MemoryAdapter(); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Memory\MemoryAdapter(); + }, ]); $storage->createDir('/', 'test'); @@ -85,12 +79,9 @@ class ArchiverTest extends TestCase $storage = new Filesystem(); $storage->init([ 'separator' => '/', - 'filesystem_adapter' => 'memoryadapter', - 'adapters' => [ - 'memoryadapter' => function () { - return new \League\Flysystem\Memory\MemoryAdapter(); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Memory\MemoryAdapter(); + }, ]); $storage->createDir('/', 'test'); @@ -110,12 +101,9 @@ class ArchiverTest extends TestCase $storage = new Filesystem(); $storage->init([ 'separator' => '/', - 'filesystem_adapter' => 'memoryadapter', - 'adapters' => [ - 'memoryadapter' => function () { - return new \League\Flysystem\Memory\MemoryAdapter(); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Memory\MemoryAdapter(); + }, ]); $stream = fopen(TEST_ARCHIVE, 'r'); diff --git a/tests/backend/Unit/FilesystemTest.php b/tests/backend/Unit/FilesystemTest.php index 718672e..ebd83e2 100644 --- a/tests/backend/Unit/FilesystemTest.php +++ b/tests/backend/Unit/FilesystemTest.php @@ -33,14 +33,11 @@ class FilesystemTest extends TestCase $this->storage = new Filesystem(); $this->storage->init([ 'separator' => '/', - 'filesystem_adapter' => 'localfilesystem', - 'adapters' => [ - 'localfilesystem' => function () { - return new \League\Flysystem\Adapter\Local( - TEST_REPOSITORY - ); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Adapter\Local( + TEST_REPOSITORY + ); + }, ]); } diff --git a/tests/backend/configuration.php b/tests/backend/configuration.php index be832ee..b05392d 100644 --- a/tests/backend/configuration.php +++ b/tests/backend/configuration.php @@ -52,14 +52,11 @@ return [ 'handler' => '\Filegator\Services\Storage\Filesystem', 'config' => [ 'separator' => '/', - 'filesystem_adapter' => 'localfilesystem', - 'adapters' => [ - 'localfilesystem' => function () { - return new \League\Flysystem\Adapter\Local( - TEST_REPOSITORY - ); - }, - ], + 'adapter' => function () { + return new \League\Flysystem\Adapter\Local( + TEST_REPOSITORY + ); + }, ], ], 'Filegator\Services\Auth\AuthInterface' => [