Skip to content

Commit

Permalink
Use a visibility converter service instead of a string (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead authored Oct 15, 2024
1 parent 23d7186 commit b5f0caa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/adapter_async_aws_s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the S3 client at [async-aws.com](https://async-aws.com/clients/) or use the
```yml
services:
acme.async.portable_visibility_converter:
class: League\Flysystem\AsyncAwsS3\PortableVisibilityConverter:
class: League\Flysystem\AsyncAwsS3\PortableVisibilityConverter

acme.async_s3_client:
class: AsyncAws\S3\S3Client
Expand Down
4 changes: 4 additions & 0 deletions doc/adapter_awss3.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ This version requires you to use the "v4" of the signature.

```yml
services:
acme.awss3v3.portable_visibility_converter:
class: League\Flysystem\AwsS3V3\PortableVisibilityConverter

acme.s3_client:
class: Aws\S3\S3Client
arguments:
Expand All @@ -32,6 +35,7 @@ oneup_flysystem:
client: acme.s3_client
bucket: 'bucket-name'
prefix: 'path/prefix' # Optional path prefix, you can set empty string
visibilityConverter: acme.awss3v3.portable_visibility_converter
```

For more details on the other parameters, take a look at the [Flysystem documentation](https://flysystem.thephpleague.com/v2/docs/adapter/aws-s3-v3/).
Expand Down
4 changes: 4 additions & 0 deletions doc/adapter_ftp.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ You have to provide at least a value for the `host` key.
```yml
# app/config/config.yml
oneup_flysystem:
acme.ftp.portable_visibility_converter:
class: League\Flysystem\UnixVisibility\PortableVisibilityConverter

adapters:
my_adapter:
ftp:
Expand All @@ -14,6 +17,7 @@ oneup_flysystem:
root: '/upload' # required
username: 'username' # required
password: 'password' # required
visibilityConverter: acme.ftp.portable_visibility_converter
```
For more details on the other parameters, take a look at the [Flysystem documentation](https://flysystem.thephpleague.com/v2/docs/adapter/ftp/).
Expand Down
4 changes: 3 additions & 1 deletion src/DependencyInjection/Factory/Adapter/AwsS3V3Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public function getKey(): string

public function create(ContainerBuilder $container, string $id, array $config): void
{
$visibilityConverter = $config['visibilityConverter'] ? new Reference($config['visibilityConverter']) : null;

$container
->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.awss3v3'))
->replaceArgument(0, new Reference($config['client']))
->replaceArgument(1, $config['bucket'])
->replaceArgument(2, $config['prefix'])
->replaceArgument(3, $config['visibilityConverter'])
->replaceArgument(3, $visibilityConverter)
->replaceArgument(4, $config['mimeTypeDetector'])
->replaceArgument(5, (array) $config['options'])
->replaceArgument(6, $config['streamReads'])
Expand Down
5 changes: 4 additions & 1 deletion src/DependencyInjection/Factory/Adapter/FtpFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class FtpFactory implements AdapterFactoryInterface
{
Expand All @@ -20,6 +21,8 @@ public function getKey(): string

public function create(ContainerBuilder $container, string $id, array $config): void
{
$visibilityConverter = $config['visibilityConverter'] ? new Reference($config['visibilityConverter']) : null;

$container
->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.ftp'))
->replaceArgument(0,
Expand All @@ -30,7 +33,7 @@ public function create(ContainerBuilder $container, string $id, array $config):
)
->replaceArgument(1, $config['connectionProvider'])
->replaceArgument(2, $config['connectivityChecker'])
->replaceArgument(3, $config['visibilityConverter'])
->replaceArgument(3, $visibilityConverter)
->replaceArgument(4, $config['mimeTypeDetector'])
;
}
Expand Down

0 comments on commit b5f0caa

Please sign in to comment.