-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add google cloud storage adapter (#238)
- Loading branch information
Showing
7 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use the Google Cloud Storage adapter | ||
|
||
This adapter connects to the filesystem in the Google Cloud Storage. | ||
|
||
|
||
```yml | ||
oneup_flysystem: | ||
adapters: | ||
acme.flysystem_adapter: | ||
googlecloudstorage: | ||
client: 'google_cloud_storage_client' # Service ID of the Google\Cloud\Storage\StorageClient | ||
bucket: 'my_gcs_bucket' | ||
prefix: '' | ||
``` | ||
For more details on the other parameters, take a look at the [Flysystem documentation](https://flysystem.thephpleague.com/v2/docs/adapter/gcs/). | ||
## More to know | ||
* [Create and use your filesystem](filesystem_create.md) |
49 changes: 49 additions & 0 deletions
49
src/DependencyInjection/Factory/Adapter/GoogleCloudStorageFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter; | ||
|
||
use League\Flysystem\Visibility; | ||
use Oneup\FlysystemBundle\DependencyInjection\Factory\AdapterFactoryInterface; | ||
use Symfony\Component\Config\Definition\Builder\NodeDefinition; | ||
use Symfony\Component\DependencyInjection\ChildDefinition; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class GoogleCloudStorageFactory implements AdapterFactoryInterface | ||
{ | ||
public function getKey(): string | ||
{ | ||
return 'googlecloudstorage'; | ||
} | ||
|
||
public function create(ContainerBuilder $container, string $id, array $config): void | ||
{ | ||
$bucket = new Definition(); | ||
$bucket->setFactory([new Reference($config['client']), 'bucket']); | ||
$bucket->setArgument(0, $config['bucket']); | ||
|
||
$container | ||
->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.googlecloudstorage')) | ||
->replaceArgument(0, $bucket) | ||
->replaceArgument(1, $config['prefix']) | ||
->replaceArgument(2, $config['visibilityHandler']) | ||
->replaceArgument(3, $config['defaultVisiblity']) | ||
; | ||
} | ||
|
||
public function addConfiguration(NodeDefinition $node): void | ||
{ | ||
$node | ||
->children() | ||
->scalarNode('client')->isRequired()->end() | ||
->scalarNode('bucket')->isRequired()->end() | ||
->scalarNode('prefix')->treatNullLike('')->defaultValue('')->end() | ||
->scalarNode('visibilityHandler')->defaultNull()->end() | ||
->scalarNode('defaultVisiblity')->defaultValue(Visibility::PRIVATE)->end() | ||
->end() | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters