From c071643658345e687280d9ef9412cec15432bc46 Mon Sep 17 00:00:00 2001 From: MD Nurullah Date: Wed, 30 Nov 2022 18:05:25 +0530 Subject: [PATCH 1/6] support for the azure blob --- README.md | 1 + .../Factory/Adapter/AzureBlobFactory.php | 40 +++++++++++++++++++ src/Resources/config/adapters.xml | 5 +++ src/Resources/config/factories.xml | 4 ++ 4 files changed, 50 insertions(+) create mode 100644 src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php diff --git a/README.md b/README.md index c8d55c4..77fae61 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ The OneupFlysystemBundle provides a [Flysystem](https://github.com/thephpleague/ * [Google Cloud Storage](https://cloud.google.com/storage) * [AsyncAwsS3](https://async-aws.com/) * [AwsS3](http://aws.amazon.com/de/sdkforphp/) +* [AzureBlobStorage](https://azure.microsoft.com/en-us/services/storage/blobs/) * [Ftp](http://php.net/manual/en/book.ftp.php) * [Local filesystem](http://php.net/manual/en/ref.filesystem.php) * [Sftp](http://phpseclib.sourceforge.net/sftp/intro.html) diff --git a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php new file mode 100644 index 0000000..a6a100e --- /dev/null +++ b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php @@ -0,0 +1,40 @@ +setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.azureblob')) + ->replaceArgument(0, new Reference($config['client'])) + ->replaceArgument(1, $config['container']) + ->replaceArgument(2, $config['prefix']) + ; + } + + public function addConfiguration(NodeDefinition $node): void + { + $node + ->children() + ->scalarNode('client')->isRequired()->end() + ->scalarNode('container')->isRequired()->end() + ->scalarNode('prefix')->defaultNull()->end() + ->end() + ; + } +} diff --git a/src/Resources/config/adapters.xml b/src/Resources/config/adapters.xml index 8b6d473..3a7f304 100644 --- a/src/Resources/config/adapters.xml +++ b/src/Resources/config/adapters.xml @@ -53,5 +53,10 @@ + + + + + diff --git a/src/Resources/config/factories.xml b/src/Resources/config/factories.xml index 01923a4..e58603f 100644 --- a/src/Resources/config/factories.xml +++ b/src/Resources/config/factories.xml @@ -40,5 +40,9 @@ class="Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter\GitlabFactory"> + + + From fe3675d59e35f352fcf3ae017cbd206d37963976 Mon Sep 17 00:00:00 2001 From: MD Nurullah Date: Wed, 30 Nov 2022 20:39:17 +0530 Subject: [PATCH 2/6] support for the azure blob --- src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php index a6a100e..cce7280 100644 --- a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php +++ b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php @@ -1,5 +1,7 @@ Date: Thu, 1 Dec 2022 17:44:27 +0530 Subject: [PATCH 3/6] fixed issues for Azure blob support --- composer.json | 1 + .../Factory/Adapter/AzureBlobFactory.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 4688803..84948d9 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "league/flysystem-google-cloud-storage": "^2.0 || ^3.0", "league/flysystem-memory": "^2.0 || ^3.0", "league/flysystem-sftp": "^2.0 || ^3.0", + "league/flysystem-azure-blob-storage": "^3.0", "phpstan/phpstan": "^1.4", "phpunit/phpunit": "^9.5", "royvoetman/flysystem-gitlab-storage": "^2.0 || ^3.0", diff --git a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php index cce7280..3b0fa0b 100644 --- a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php +++ b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php @@ -4,11 +4,11 @@ namespace Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter; +use Oneup\FlysystemBundle\DependencyInjection\Factory\AdapterFactoryInterface; use Symfony\Component\Config\Definition\Builder\NodeDefinition; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Oneup\FlysystemBundle\DependencyInjection\Factory\AdapterFactoryInterface; class AzureBlobFactory implements AdapterFactoryInterface { @@ -19,7 +19,7 @@ public function getKey(): string public function create(ContainerBuilder $container, $id, array $config): void { - $definition = $container + $container ->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.azureblob')) ->replaceArgument(0, new Reference($config['client'])) ->replaceArgument(1, $config['container']) From 6e5e67c518fa44a57db83369ac2d21f1886bda5b Mon Sep 17 00:00:00 2001 From: David Greminger Date: Thu, 1 Dec 2022 13:32:41 +0100 Subject: [PATCH 4/6] Drop PHP 7 support --- .github/workflows/ci.yml | 10 +++------- composer.json | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94de90a..685446f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@2.7.0 with: - php-version: 7.4 + php-version: 8.0 extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo, zlib coverage: none @@ -36,12 +36,8 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 8.0, 8.1] + php: [8.0, 8.1] symfony: [4.4, 5.4, 6.0] - exclude: - # Symfony 6.0 does not supports php <8.0 - - php: 7.4 - symfony: 6.0 steps: - name: Setup PHP uses: shivammathur/setup-php@2.7.0 @@ -67,7 +63,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@2.7.0 with: - php-version: 7.4 + php-version: 8.0 extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, pcre, pdo_mysql, zlib coverage: none diff --git a/composer.json b/composer.json index 84948d9..a201af3 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "league/flysystem": "^2.0 || ^3.0", "symfony/config": "^4.4 || ^5.3 || ^6.0", "symfony/dependency-injection": "^4.4 || ^5.3 || ^6.0", From c07eec5db59ba92f7614b1c1efb61cf792080fd7 Mon Sep 17 00:00:00 2001 From: David Greminger Date: Thu, 1 Dec 2022 13:36:11 +0100 Subject: [PATCH 5/6] Fix PHPStan issues --- src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php | 2 +- src/DependencyInjection/Factory/Adapter/LocalFactory.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php index 3b0fa0b..a07f5b4 100644 --- a/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php +++ b/src/DependencyInjection/Factory/Adapter/AzureBlobFactory.php @@ -17,7 +17,7 @@ public function getKey(): string return 'azureblob'; } - public function create(ContainerBuilder $container, $id, array $config): void + public function create(ContainerBuilder $container, string $id, array $config): void { $container ->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.azureblob')) diff --git a/src/DependencyInjection/Factory/Adapter/LocalFactory.php b/src/DependencyInjection/Factory/Adapter/LocalFactory.php index fe03133..79b9d71 100644 --- a/src/DependencyInjection/Factory/Adapter/LocalFactory.php +++ b/src/DependencyInjection/Factory/Adapter/LocalFactory.php @@ -26,7 +26,7 @@ public function create(ContainerBuilder $container, string $id, array $config): if (isset($config['permissions']) && null !== $config['permissions']) { $visibilityConverter = new Definition(PortableVisibilityConverter::class); $visibilityConverter->setFactory([PortableVisibilityConverter::class, 'fromArray']); - $visibilityConverter->setArgument(0, $config['permissions'] ?? []); + $visibilityConverter->setArgument(0, $config['permissions']); } $container From c15f911b11e65b628d588b43594f46b78c41b963 Mon Sep 17 00:00:00 2001 From: David Greminger Date: Thu, 1 Dec 2022 13:44:02 +0100 Subject: [PATCH 6/6] Add docs --- doc/adapter_azure_blob_storage.md | 20 ++++++++++++++++++++ doc/index.md | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 doc/adapter_azure_blob_storage.md diff --git a/doc/adapter_azure_blob_storage.md b/doc/adapter_azure_blob_storage.md new file mode 100644 index 0000000..5315546 --- /dev/null +++ b/doc/adapter_azure_blob_storage.md @@ -0,0 +1,20 @@ +# Use the Azure Blob Storage adapter + +This adapter connects to the filesystem in the Azure Blob Storage. + + +```yml +oneup_flysystem: + adapters: + acme.flysystem_adapter: + azureblob: + client: 'azure_blob_storage_client' # Service ID of the MicrosoftAzure\Storage\Blob\BlobRestProxy + container: 'container-name' + prefix: 'optional/prefix' +``` + +For more details on the other parameters, take a look at the [Flysystem documentation](https://flysystem.thephpleague.com/docs/adapter/azure-blob-storage/). + +## More to know + +* [Create and use your filesystem](filesystem_create.md) diff --git a/doc/index.md b/doc/index.md index f1b787b..9e8b389 100644 --- a/doc/index.md +++ b/doc/index.md @@ -28,6 +28,7 @@ Composer will now fetch and install this bundle in the vendor directory `vendor/ * The InMemory adapter requires `"league/flysystem-memory"` * The AsyncAwsS3 adapter requires `"league/flysystem-async-aws-s3"` * The Gitlab adapter requires `"royvoetman/flysystem-gitlab-storage"` +* The Azure Blob Storage adapter requires `"league/flysystem-azure-blob-storage"` ### Step 2: Enable the bundle Enable the bundle in the kernel: @@ -78,6 +79,7 @@ There are a bunch of adapters for you to use: * [InMemoryAdapter](adapter_in_memory.md) * [Sftp](adapter_sftp.md) * [Gitlab](adapter_gitlab.md) +* [AzureBlobStorage](adapter_azure_blob_storage.md) * [Custom](adapter_custom.md) ### Step 4: Next steps