Skip to content

Commit

Permalink
fix/improve filesystem visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-efler committed Apr 27, 2021
1 parent ec400ce commit 2f8108f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Option/LocalOption.php
Expand Up @@ -15,6 +15,7 @@
use Ixocreate\ServiceManager\ServiceManagerInterface;
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
use League\Flysystem\Visibility;

final class LocalOption implements OptionInterface
{
Expand Down Expand Up @@ -202,7 +203,8 @@ public function create(string $name, ServiceManagerInterface $serviceManager): A
$this->config['permission']['file']['public'],
$this->config['permission']['file']['private'],
$this->config['permission']['dir']['public'],
$this->config['permission']['dir']['private']
$this->config['permission']['dir']['private'],
Visibility::PUBLIC
);

return new Adapter(
Expand Down
19 changes: 18 additions & 1 deletion src/Option/S3Option.php
Expand Up @@ -25,6 +25,7 @@ final class S3Option implements OptionInterface
'version' => 'latest',
'bucketName' => '',
'initialPath' => '',
'visibility' => null,
'options' => [],
];

Expand Down Expand Up @@ -78,6 +79,16 @@ public function bucketName(): string
return $this->config['bucketName'];
}

public function setVisibility(string $visibility): void
{
$this->config['visibility'] = $visibility;
}

public function visibility(): ?string
{
return $this->config['visibility'];
}

public function setInitialPath(string $initialPath): void
{
$this->config['initialPath'] = $initialPath;
Expand Down Expand Up @@ -145,6 +156,12 @@ public function unserialize($serialized)
*/
public function create(string $name, ServiceManagerInterface $serviceManager): AdapterInterface
{
$visibility = null;
if ($this->visibility() !== null) {
$visibility = $this->visibility();
$visibility = new $visibility();
}

return new Adapter(
new AwsS3V3Adapter(
new S3Client([
Expand All @@ -157,7 +174,7 @@ public function create(string $name, ServiceManagerInterface $serviceManager): A
]),
$this->bucketName(),
$this->initialPath(),
null,
$visibility,
null,
$this->options()
)
Expand Down

0 comments on commit 2f8108f

Please sign in to comment.