Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3 #115

Merged
merged 8 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.19.0/php-cs-fixer.phar -q
php php-cs-fixer.phar fix --dry-run --diff

tests-php-7-2-symfony-4-4:
tests-php-8-0-symfony-4-4:
runs-on: ubuntu-latest
env:
SYMFONY_VERSION: 4.4.*
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
php-version: '8.0'
coverage: none
- name: PHPUnit
run: |
Expand All @@ -37,23 +37,6 @@ jobs:
composer update --prefer-lowest --prefer-dist --no-interaction --no-ansi --no-progress
php vendor/bin/simple-phpunit

tests-php-7-4-symfony-5-3:
runs-on: ubuntu-latest
env:
SYMFONY_VERSION: 5.3.*
steps:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
- name: PHPUnit
run: |
composer require --no-update symfony/config=$SYMFONY_VERSION symfony/http-kernel=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/options-resolver=$SYMFONY_VERSION
composer require --no-update --dev symfony/framework-bundle=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION
composer update --prefer-dist --no-interaction --no-ansi --no-progress
php vendor/bin/simple-phpunit

tests-php-8-0-symfony-5-4:
runs-on: ubuntu-latest
env:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ to interact with your storage.
2. Cloud storage providers:
[AsyncAws S3](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#asyncaws-s3),
[AWS SDK S3](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#aws-sdk-s3),
[Azure](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#azure),
[Google Cloud Storage](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#google-cloud-storage),
[DigitalOcean Spaces](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#digitalocean-spaces),
[Scaleway Object Storage](https://github.com/thephpleague/flysystem-bundle/blob/master/docs/2-cloud-storage-providers.md#scaleway-object-storage)
Expand Down
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "league/flysystem-bundle",
"description": "Symfony bundle integrating Flysystem into Symfony 4.2+ applications",
"description": "Symfony bundle integrating Flysystem into Symfony 4.4+ applications",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
Expand All @@ -20,26 +20,27 @@
}
},
"require": {
"php": ">=7.2",
"league/flysystem": "^2.1|^3.0",
"symfony/config": "^4.2|^5.0|^6.0",
"php": "^8.0",
"league/flysystem": "^3.0",
"symfony/config": "^4.4|^5.0|^6.0",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/http-kernel": "^4.2|^5.0|^6.0",
"symfony/dependency-injection": "^4.2|^5.0|^6.0",
"symfony/options-resolver": "^4.2|^5.0|^6.0"
"symfony/http-kernel": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/options-resolver": "^4.4|^5.0|^6.0"
},
"require-dev": {
"league/flysystem-async-aws-s3": "^2.0|^3.0",
"league/flysystem-aws-s3-v3": "^2.0|^3.0",
"league/flysystem-azure-blob-storage": "^3.1",
"league/flysystem-ftp": "^2.0|^3.0",
"league/flysystem-google-cloud-storage": "^2.0|^3.0",
"league/flysystem-memory": "^2.0|^3.0",
"league/flysystem-sftp-v3": "^2.0|^3.0",
"symfony/dotenv": "^4.2|^5.0|^6.0",
"symfony/framework-bundle": "^4.2|^5.0|^6.0",
"symfony/dotenv": "^4.4|^5.0|^6.0",
"symfony/framework-bundle": "^4.4|^5.0|^6.0",
"symfony/phpunit-bridge": "^5.2",
"symfony/var-dumper": "^4.1|^5.0|^6.0",
"symfony/yaml": "^4.2|^5.0|^6.0"
"symfony/var-dumper": "^4.4|^5.0|^6.0",
"symfony/yaml": "^4.4|^5.0|^6.0"
},
"conflict": {
"league/flysystem-cached-adapter": "<1.0.9"
Expand Down
24 changes: 24 additions & 0 deletions docs/2-cloud-storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,36 @@ One of the core feature of Flysystem is its ability to interact easily with remo
including many cloud storage providers. This bundle provides the same level of support for these
cloud providers by providing corresponding adapters in the configuration.

* [Azure](#azure)
* [AsyncAws S3](#asyncaws-s3)
* [AWS S3](#aws-sdk-s3)
* [DigitalOcean Spaces](#digitalocean-spaces)
* [Scaleway Object Storage](#scaleway-object-storage)
* [Google Cloud Storage](#google-cloud-storage)

## Azure

### Installation

```
composer require league/flysystem-azure-blob-storage
```

### Usage

```yaml
# config/packages/flysystem.yaml

flysystem:
storages:
users.storage:
adapter: 'azure'
options:
client: 'azure_client_service' # The service ID of the MicrosoftAzure\Storage\Blob\BlobRestProxy instance
container: 'container_name'
prefix: 'optional/path/prefix'
```

## AsyncAws S3

### Installation
Expand Down
10 changes: 8 additions & 2 deletions docs/B-configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ flysystem:
client: 'aws_client_service'
bucket: 'bucket_name'
prefix: 'optional/path/prefix'

users2.storage:
adapter: 'custom_adapter'
adapter: 'azure'
options:
client: 'azure_client_service'
container: 'container_name'
prefix: 'optional/path/prefix'

users3.storage:
adapter: 'ftp'
Expand Down Expand Up @@ -72,4 +76,6 @@ flysystem:
options:
source: 'flysystem_storage_service_to_use'

users10.storage:
adapter: 'custom_adapter'
```
1 change: 1 addition & 0 deletions src/Adapter/AdapterDefinitionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct()
$this->builders = [
new Builder\AsyncAwsAdapterDefinitionBuilder(),
new Builder\AwsAdapterDefinitionBuilder(),
new Builder\AzureAdapterDefinitionBuilder(),
new Builder\FtpAdapterDefinitionBuilder(),
new Builder\GcloudAdapterDefinitionBuilder(),
new Builder\LocalAdapterDefinitionBuilder(),
Expand Down
57 changes: 57 additions & 0 deletions src/Adapter/Builder/AzureAdapterDefinitionBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of the flysystem-bundle project.
*
* (c) Titouan Galopin <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace League\FlysystemBundle\Adapter\Builder;

use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @author Titouan Galopin <[email protected]>
*
* @internal
*/
class AzureAdapterDefinitionBuilder extends AbstractAdapterDefinitionBuilder
{
public function getName(): string
{
return 'azure';
}

protected function getRequiredPackages(): array
{
return [
AzureBlobStorageAdapter::class => 'league/flysystem-azure-blob-storage',
];
}

protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('client');
$resolver->setAllowedTypes('client', 'string');

$resolver->setRequired('container');
$resolver->setAllowedTypes('container', 'string');

$resolver->setDefault('prefix', '');
$resolver->setAllowedTypes('prefix', 'string');
}

protected function configureDefinition(Definition $definition, array $options)
{
$definition->setClass(AzureBlobStorageAdapter::class);
$definition->setArgument(0, new Reference($options['client']));
$definition->setArgument(1, $options['container']);
$definition->setArgument(2, $options['prefix']);
}
}
62 changes: 62 additions & 0 deletions tests/Adapter/Builder/AzureAdapterDefinitionBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
* This file is part of the flysystem-bundle project.
*
* (c) Titouan Galopin <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Tests\League\FlysystemBundle\Adapter\Builder;

use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
use League\FlysystemBundle\Adapter\Builder\AzureAdapterDefinitionBuilder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Reference;

class AzureAdapterDefinitionBuilderTest extends TestCase
{
public function createBuilder()
{
return new AzureAdapterDefinitionBuilder();
}

public function provideValidOptions()
{
yield 'minimal' => [[
'client' => 'my_client',
'container' => 'container_name',
]];

yield 'prefix' => [[
'client' => 'my_client',
'container' => 'container_name',
'prefix' => 'prefix/path',
]];
}

/**
* @dataProvider provideValidOptions
*/
public function testCreateDefinition($options)
{
$this->assertSame(AzureBlobStorageAdapter::class, $this->createBuilder()->createDefinition($options)->getClass());
}

public function testOptionsBehavior()
{
$definition = $this->createBuilder()->createDefinition([
'client' => 'my_client',
'container' => 'container_name',
'prefix' => 'prefix/path',
]);

$this->assertSame(AzureBlobStorageAdapter::class, $definition->getClass());
$this->assertInstanceOf(Reference::class, $definition->getArgument(0));
$this->assertSame('my_client', (string) $definition->getArgument(0));
$this->assertSame('container_name', $definition->getArgument(1));
$this->assertSame('prefix/path', $definition->getArgument(2));
}
}
7 changes: 7 additions & 0 deletions tests/Adapter/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ fs_aws:
bucket: 'bucket_name'
prefix: 'optional/path/prefix'

fs_azure:
adapter: 'azure'
options:
client: 'azure_client_service'
container: 'container_name'
prefix: 'optional/path/prefix'

fs_ftp:
adapter: 'ftp'
options:
Expand Down
3 changes: 3 additions & 0 deletions tests/DependencyInjection/FlysystemExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Google\Cloud\Storage\Bucket;
use Google\Cloud\Storage\StorageClient;
use League\Flysystem\FilesystemOperator;
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Dotenv\Dotenv;
use Tests\League\FlysystemBundle\Kernel\FlysystemAppKernel;
Expand All @@ -26,6 +27,7 @@ public function provideFilesystems()
{
$fsNames = [
'fs_aws',
'fs_azure',
'fs_custom',
'fs_ftp',
'fs_gcloud',
Expand Down Expand Up @@ -99,6 +101,7 @@ private function getClientMocks()
return [
'aws_client_service' => $this->createMock(S3Client::class),
'asyncaws_client_service' => $this->createMock(AsyncS3Client::class),
'azure_client_service' => $this->createMock(BlobRestProxy::class),
'gcloud_client_service' => $gcloud,
];
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Kernel/config/flysystem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ flysystem:
bucket: '%env(AWS_BUCKET)%'
prefix: 'optional/path/prefix'

fs_azure:
adapter: 'azure'
options:
client: 'azure_client_service'
container: 'container_name'
prefix: 'optional/path/prefix'

fs_custom:
adapter: 'custom_adapter'

Expand Down
1 change: 1 addition & 0 deletions tests/Kernel/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
# Aliases used to test the services construction
flysystem.test.fs_asyncaws: { alias: 'fs_asyncaws' }
flysystem.test.fs_aws: { alias: 'fs_aws' }
flysystem.test.fs_azure: { alias: 'fs_azure' }
flysystem.test.fs_custom: { alias: 'fs_custom' }
flysystem.test.fs_ftp: { alias: 'fs_ftp' }
flysystem.test.fs_gcloud: { alias: 'fs_gcloud' }
Expand Down