mirror of
https://github.com/filegator/filegator.git
synced 2025-08-01 00:20:16 +02:00
storage config simplified
This commit is contained in:
@@ -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);
|
||||
|
@@ -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' => [
|
||||
|
@@ -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);
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
|
@@ -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');
|
||||
|
@@ -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
|
||||
);
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -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' => [
|
||||
|
Reference in New Issue
Block a user