From 4480f3f9cf7feab4345843db9149d1387da76331 Mon Sep 17 00:00:00 2001 From: Rudolf Krupa Date: Tue, 4 Jan 2022 17:58:10 +0100 Subject: [PATCH 1/2] hyperia --- README.md | 35 ++++++-------- composer.json | 13 +++-- src/Bus.php | 12 ++--- src/CommandBuilder.php | 12 ++--- src/CommandFactory.php | 48 +++++++++---------- src/HandlerResolver.php | 14 +++--- src/Service.php | 26 +++++----- src/base/commands/ExecutableCommand.php | 12 ++--- src/base/commands/traits/Async.php | 4 +- src/base/commands/traits/Options.php | 4 +- src/base/handlers/Handler.php | 6 +-- src/commands/DeleteCommand.php | 16 +++---- src/commands/ExistCommand.php | 10 ++-- src/commands/GetCommand.php | 16 +++---- src/commands/GetPresignedUrlCommand.php | 8 ++-- src/commands/GetUrlCommand.php | 8 ++-- src/commands/ListCommand.php | 16 +++---- src/commands/PutCommand.php | 18 +++---- src/commands/RestoreCommand.php | 14 +++--- src/commands/UploadCommand.php | 14 +++--- src/handlers/ExistCommandHandler.php | 10 ++-- .../GetPresignedUrlCommandHandler.php | 10 ++-- src/handlers/GetUrlCommandHandler.php | 10 ++-- src/handlers/PlainCommandHandler.php | 16 +++---- src/handlers/UploadCommandHandler.php | 10 ++-- src/interfaces/Bus.php | 8 ++-- src/interfaces/CommandBuilder.php | 8 ++-- src/interfaces/HandlerResolver.php | 12 ++--- src/interfaces/Service.php | 10 ++-- src/interfaces/commands/Asynchronous.php | 4 +- src/interfaces/commands/Command.php | 4 +- src/interfaces/commands/ExecutableCommand.php | 4 +- src/interfaces/commands/HasAcl.php | 4 +- src/interfaces/commands/HasBucket.php | 4 +- src/interfaces/commands/PlainCommand.php | 4 +- src/interfaces/handlers/Handler.php | 4 +- 36 files changed, 213 insertions(+), 215 deletions(-) mode change 100644 => 100755 src/Bus.php mode change 100644 => 100755 src/CommandBuilder.php mode change 100644 => 100755 src/CommandFactory.php mode change 100644 => 100755 src/HandlerResolver.php mode change 100644 => 100755 src/Service.php mode change 100644 => 100755 src/base/commands/ExecutableCommand.php mode change 100644 => 100755 src/base/commands/traits/Async.php mode change 100644 => 100755 src/base/commands/traits/Options.php mode change 100644 => 100755 src/base/handlers/Handler.php mode change 100644 => 100755 src/commands/DeleteCommand.php mode change 100644 => 100755 src/commands/ExistCommand.php mode change 100644 => 100755 src/commands/GetCommand.php mode change 100644 => 100755 src/commands/GetPresignedUrlCommand.php mode change 100644 => 100755 src/commands/GetUrlCommand.php mode change 100644 => 100755 src/commands/ListCommand.php mode change 100644 => 100755 src/commands/PutCommand.php mode change 100644 => 100755 src/commands/RestoreCommand.php mode change 100644 => 100755 src/commands/UploadCommand.php mode change 100644 => 100755 src/handlers/ExistCommandHandler.php mode change 100644 => 100755 src/handlers/GetPresignedUrlCommandHandler.php mode change 100644 => 100755 src/handlers/GetUrlCommandHandler.php mode change 100644 => 100755 src/handlers/PlainCommandHandler.php mode change 100644 => 100755 src/handlers/UploadCommandHandler.php mode change 100644 => 100755 src/interfaces/Bus.php mode change 100644 => 100755 src/interfaces/CommandBuilder.php mode change 100644 => 100755 src/interfaces/HandlerResolver.php mode change 100644 => 100755 src/interfaces/Service.php mode change 100644 => 100755 src/interfaces/commands/Asynchronous.php mode change 100644 => 100755 src/interfaces/commands/Command.php mode change 100644 => 100755 src/interfaces/commands/ExecutableCommand.php mode change 100644 => 100755 src/interfaces/commands/HasAcl.php mode change 100644 => 100755 src/interfaces/commands/HasBucket.php mode change 100644 => 100755 src/interfaces/commands/PlainCommand.php mode change 100644 => 100755 src/interfaces/handlers/Handler.php diff --git a/README.md b/README.md index 02c7c55..12e1262 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,14 @@ An Amazon S3 component for Yii2. -[![License](https://poser.pugx.org/frostealth/yii2-aws-s3/license)](https://github.com/frostealth/yii2-aws-s3/blob/2.x/LICENSE) -[![Latest Stable Version](https://poser.pugx.org/frostealth/yii2-aws-s3/v/stable)](https://packagist.org/packages/frostealth/yii2-aws-s3) -[![Total Downloads](https://poser.pugx.org/frostealth/yii2-aws-s3/downloads)](https://packagist.org/packages/frostealth/yii2-aws-s3) -[![Latest Unstable Version](https://poser.pugx.org/frostealth/yii2-aws-s3/v/unstable)](https://packagist.org/packages/frostealth/yii2-aws-s3) - > Yii2 AWS S3 uses [SemVer](http://semver.org/). -> Version 2.x requires PHP 7. For PHP less 7.0 use [1.x](https://github.com/frostealth/yii2-aws-s3/tree/1.x). - ## Installation 1. Run the [Composer](http://getcomposer.org/download/) command to install the latest version: ```bash - composer require frostealth/yii2-aws-s3 ~2.0 + composer require hyperia/yii2-aws-s3 ~2.0 ``` 2. Add the component to `config/main.php` @@ -25,7 +18,7 @@ An Amazon S3 component for Yii2. 'components' => [ // ... 's3' => [ - 'class' => 'frostealth\yii2\aws\s3\Service', + 'class' => 'hyperia\yii2\aws\s3\Service', 'credentials' => [ // Aws\Credentials\CredentialsInterface|array|callable 'key' => 'my-key', 'secret' => 'my-secret', @@ -43,7 +36,7 @@ An Amazon S3 component for Yii2. ### Usage of the command factory and additional params ```php -/** @var \frostealth\yii2\aws\s3\Service $s3 */ +/** @var \hyperia\yii2\aws\s3\Service $s3 */ $s3 = Yii::$app->get('s3'); /** @var \Aws\ResultInterface $result */ @@ -72,7 +65,7 @@ $signedUrl = $s3->commands()->getPresignedUrl('filename.ext', '+2 days')->execut ### Short syntax ```php -/** @var \frostealth\yii2\aws\s3\Service $s3 */ +/** @var \hyperia\yii2\aws\s3\Service $s3 */ $s3 = Yii::$app->get('s3'); /** @var \Aws\ResultInterface $result */ @@ -101,7 +94,7 @@ $signedUrl = $s3->getPresignedUrl('filename.ext', '+2 days'); ### Asynchronous execution ```php -/** @var \frostealth\yii2\aws\s3\Service $s3 */ +/** @var \hyperia\yii2\aws\s3\Service $s3 */ $s3 = Yii::$app->get('s3'); /** @var \GuzzleHttp\Promise\PromiseInterface $promise */ @@ -119,10 +112,10 @@ $promise = $s3->commands()->list('path/')->async()->execute(); ## Advanced usage ```php -/** @var \frostealth\yii2\aws\s3\interfaces\Service $s3 */ +/** @var \hyperia\yii2\aws\s3\interfaces\Service $s3 */ $s3 = Yii::$app->get('s3'); -/** @var \frostealth\yii2\aws\s3\commands\GetCommand $command */ +/** @var \hyperia\yii2\aws\s3\commands\GetCommand $command */ $command = $s3->create(GetCommand::class); $command->inBucket('my-another-bucket')->byFilename('filename.ext')->saveAs('/path/to/local/file.ext'); @@ -158,9 +151,9 @@ Consider the following command: namespace app\components\s3\commands; -use frostealth\yii2\aws\s3\base\commands\traits\Options; -use frostealth\yii2\aws\s3\interfaces\commands\Command; -use frostealth\yii2\aws\s3\interfaces\commands\HasBucket; +use hyperia\yii2\aws\s3\base\commands\traits\Options; +use hyperia\yii2\aws\s3\interfaces\commands\Command; +use hyperia\yii2\aws\s3\interfaces\commands\HasBucket; class MyCommand implements Command, HasBucket { @@ -204,7 +197,7 @@ The handler for this command looks like this: namespace app\components\s3\handlers; use app\components\s3\commands\MyCommand; -use frostealth\yii2\aws\s3\base\handlers\Handler; +use hyperia\yii2\aws\s3\base\handlers\Handler; class MyCommandHandler extends Handler { @@ -222,7 +215,7 @@ class MyCommandHandler extends Handler And usage this command: ```php -/** @var \frostealth\yii2\aws\s3\interfaces\Service */ +/** @var \hyperia\yii2\aws\s3\interfaces\Service */ $s3 = Yii::$app->get('s3'); /** @var \app\components\s3\commands\MyCommand $command */ @@ -240,8 +233,8 @@ Custom plain command looks like this: namespace app\components\s3\commands; -use frostealth\yii2\aws\s3\interfaces\commands\HasBucket; -use frostealth\yii2\aws\s3\interfaces\commands\PlainCommand; +use hyperia\yii2\aws\s3\interfaces\commands\HasBucket; +use hyperia\yii2\aws\s3\interfaces\commands\PlainCommand; class MyPlainCommand implements PlainCommand, HasBucket { diff --git a/composer.json b/composer.json index b65fa0e..e506bc8 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "frostealth/yii2-aws-s3", + "name": "hyperia/yii2-aws-s3", "type": "yii2-extension", "description": "An Amazon S3 component for Yii2", "keywords": ["yii2", "aws", "s3", "aws-s3", "yii2-aws", "yii2-s3"], - "homepage": "https://github.com/frostealth/yii2-aws-s3", + "homepage": "https://github.com/hyperia-sk/yii2-aws-s3", "license": "MIT", "authors": [ { @@ -14,10 +14,15 @@ { "name": "Constantine Chuprik", "email": "constantinchuprik@gmail.com" + }, + { + "name": "Rudolf Krupa", + "email": "rudolfkrupa@hyperia.sk", + "homepage": "https://www.hyperia.sk" } ], "support": { - "issues": "https://github.com/frostealth/yii2-aws-s3/issues?state=open" + "issues": "https://github.com/hyperia-sk/yii2-aws-s3/issues?state=open" }, "require": { "php": ">=7.0.0", @@ -30,7 +35,7 @@ }, "autoload": { "psr-4": { - "frostealth\\yii2\\aws\\s3\\": "src/" + "hyperia\\yii2\\aws\\s3\\": "src/" } } } diff --git a/src/Bus.php b/src/Bus.php old mode 100644 new mode 100755 index 56a1025..ae379e2 --- a/src/Bus.php +++ b/src/Bus.php @@ -1,13 +1,13 @@ resolver->resolve($command); - + return call_user_func([$handler, 'handle'], $command); } } diff --git a/src/CommandBuilder.php b/src/CommandBuilder.php old mode 100644 new mode 100755 index 0fa21d0..4b481a4 --- a/src/CommandBuilder.php +++ b/src/CommandBuilder.php @@ -1,13 +1,13 @@ ['class' => 'Aws\S3\S3Client'], - 'resolver' => ['class' => 'frostealth\yii2\aws\s3\HandlerResolver'], - 'bus' => ['class' => 'frostealth\yii2\aws\s3\Bus'], - 'builder' => ['class' => 'frostealth\yii2\aws\s3\CommandBuilder'], - 'factory' => ['class' => 'frostealth\yii2\aws\s3\CommandFactory'], + 'resolver' => ['class' => 'hyperia\yii2\aws\s3\HandlerResolver'], + 'bus' => ['class' => 'hyperia\yii2\aws\s3\Bus'], + 'builder' => ['class' => 'hyperia\yii2\aws\s3\CommandBuilder'], + 'factory' => ['class' => 'hyperia\yii2\aws\s3\CommandFactory'], ]; } diff --git a/src/base/commands/ExecutableCommand.php b/src/base/commands/ExecutableCommand.php old mode 100644 new mode 100755 index f8c7431..a54bed2 --- a/src/base/commands/ExecutableCommand.php +++ b/src/base/commands/ExecutableCommand.php @@ -1,24 +1,24 @@ Date: Tue, 4 Jan 2022 20:10:51 +0100 Subject: [PATCH 2/2] GuzzleHttp\Psr7 stream upload fix --- src/handlers/UploadCommandHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/UploadCommandHandler.php b/src/handlers/UploadCommandHandler.php index bc47065..77606a5 100755 --- a/src/handlers/UploadCommandHandler.php +++ b/src/handlers/UploadCommandHandler.php @@ -48,6 +48,6 @@ protected function sourceToStream($source): StreamInterface $source = Psr7\try_fopen($source, 'r+'); } - return Psr7\stream_for($source); + return Psr7\Utils::streamFor($source); } }