Skip to content

Commit 543628f

Browse files
committed
Add support for google cloud storage
1 parent 3b1e770 commit 543628f

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

DependencyInjection/BMBackupManagerExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Srmklive\Dropbox\Adapter\DropboxAdapter as Dropbox2Adapter;
1111
use League\Flysystem\Rackspace\RackspaceAdapter;
1212
use League\Flysystem\Sftp\SftpAdapter;
13+
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter;
1314
use Symfony\Component\DependencyInjection\ContainerBuilder;
1415
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\DependencyInjection\Reference;
@@ -41,6 +42,7 @@ public function load(array $configs, ContainerBuilder $container)
4142
'DropboxV2' => 'backup_manager.filesystems.dropbox_v2_filesystem',
4243
'Ftp' => 'backup_manager.filesystems.ftp_filesystem',
4344
'Sftp' => 'backup_manager.filesystems.sftp_filesystem',
45+
'Gcs' => 'backup_manager.filesystems.gcs_filesystem',
4446
];
4547

4648
$filesystemDef = $container->getDefinition('backup_manager.filesystems');
@@ -75,6 +77,7 @@ private function validateStorage(array $config)
7577
'DropboxV2' => ['package'=>'srmklive/flysystem-dropbox-v2:^1.0', 'test'=>Dropbox2Adapter::class],
7678
'Ftp' => ['package'=>'league/flysystem:^1.0', 'test'=>Ftp::class],
7779
'Sftp' => ['package'=>'league/flysystem-sftp:^1.0', 'test'=>SftpAdapter::class],
80+
'Gcs' => ['package' => 'superbalist/flysystem-google-storage:^6.0', 'test' => GoogleStorageAdapter::class],
7881
];
7982

8083
foreach ($config as $key => $storageConfig) {

DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ public function getConfigTreeBuilder()
5757
case 'Sftp':
5858
$this->validateAuthenticationType(['host', 'username', 'password', 'root', 'port', 'timeout', 'privateKey'], $config, 'Sftp');
5959
break;
60+
case 'Gcs':
61+
$this->validateAuthenticationType(['project', 'keyFilePath', 'bucket', 'prefix'], $config, 'Gcs');
62+
break;
6063
default:
61-
$validTypes = ['Local', 'AwsS3', 'B2', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp'];
64+
$validTypes = ['Local', 'AwsS3', 'B2', 'Rackspace', 'Dropbox', 'DropboxV2', 'Ftp', 'Sftp', 'Gcs'];
6265
throw new InvalidConfigurationException(sprintf('Type must be one of "%s", got "%s"', implode(', ', $validTypes), $config['type']));
6366
}
6467
}

Resources/config/services.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ services:
5050
class: BackupManager\Filesystems\SftpFilesystem
5151
public: false
5252

53+
backup_manager.filesystems.gcs_filesystem:
54+
class: BackupManager\Filesystems\GcsFilesystem
55+
public: false
56+
5357
backup_manager.filesystems:
5458
class: BackupManager\Filesystems\FilesystemProvider
5559
public: false

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function testStorageTypes($type)
176176
public function validStorageTypes()
177177
{
178178
return [
179-
['Local'],['AwsS3'], ['B2'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'],
179+
['Local'],['AwsS3'], ['B2'], ['Rackspace'], ['Dropbox'], ['DropboxV2'], ['Ftp'], ['Sftp'], ['Gcs'],
180180
];
181181
}
182182
}

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
"matthiasnoback/symfony-dependency-injection-test": "^1.2 || ^2.3",
2727
"matthiasnoback/symfony-config-test": "^2.2 || ^3.1",
2828
"nyholm/symfony-bundle-test": "^1.3.1",
29+
"superbalist/flysystem-google-storage": "^6.0",
2930
"symfony/phpunit-bridge": "^3.4 || ^4.0"
3031
},
3132
"suggest": {
3233
"league/flysystem-aws-s3-v3": "To use AWS S3, version 3",
3334
"mhetreramesh/flysystem-backblaze": "To use B2",
3435
"srmklive/flysystem-dropbox-v2": "To use Dropbox",
36+
"superbalist/flysystem-google-storage": "Google Cloud Storage adapter support.",
3537
"league/flysystem-rackspace": "To use Rackspace",
3638
"league/flysystem-sftp": "To use sftp"
3739
},

0 commit comments

Comments
 (0)