Skip to content

Commit

Permalink
modify PublicCDNAdapter for Flysystem v3 (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Fexiven <[email protected]>
  • Loading branch information
Fexiven and Fexiven authored Nov 30, 2023
1 parent ec39eba commit db33c6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ SilverStripe\Core\Injector\Injector:
class: SilverStripe\S3\Adapter\PublicCDNAdapter
constructor:
s3Client: '%$Aws\S3\S3Client'
bucket: "`AWS_BUCKET_NAME`"
prefix: "`AWS_PUBLIC_BUCKET_PREFIX`"
cdnPrefix: "`AWS_PUBLIC_CDN_PREFIX`"
bucket: '`AWS_BUCKET_NAME`'
prefix: '`AWS_PUBLIC_BUCKET_PREFIX`'
visibility: null
mimeTypeDetector: null
cdnPrefix: '`AWS_PUBLIC_CDN_PREFIX`'
options: []
cdnAssetsDir: "cms-assets" # example of a custom assets folder name, which will produce https://cdn.example.com/cms-assets/Uploads/file.jpg
```
Expand Down
2 changes: 2 additions & 0 deletions _config/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ SilverStripe\Core\Injector\Injector:
s3Client: '%$Aws\S3\S3Client'
bucket: '`AWS_BUCKET_NAME`'
prefix: '`AWS_PUBLIC_BUCKET_PREFIX`'
visibility: null
mimeTypeDetector: null
cdnPrefix: '`AWS_PUBLIC_CDN_PREFIX`'
4 changes: 2 additions & 2 deletions src/Adapter/PublicCDNAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class PublicCDNAdapter extends PublicAdapter implements SilverstripePublicAdapte

protected $cdnAssetsDir;

public function __construct(S3Client $client, $bucket, $prefix = '', $cdnPrefix = '', array $options = [], $cdnAssetsDir = '')
public function __construct(S3Client $client, $bucket, $prefix = '', VisibilityConverter $visibility = null, MimeTypeDetector $mimeTypeDetector = null, $cdnPrefix = '', array $options = [], $cdnAssetsDir = '')

This comment has been minimized.

Copy link
@wilr

wilr Dec 11, 2023

Member

@Fexiven Are you missing namespaces for these?

This comment has been minimized.

Copy link
@Fexiven

Fexiven Dec 11, 2023

Author Contributor

Flysystem wants these parameters, but Silverstripe doesn't need them. That's why I set them to null. Or what exactly do you mean?

This comment has been minimized.

Copy link
@wilr

wilr Dec 11, 2023

Member

#66

Otherwise you get an PHP Warning.

{
$this->cdnPrefix = $cdnPrefix;
$this->cdnAssetsDir = $cdnAssetsDir ? $cdnAssetsDir : ASSETS_DIR;
parent::__construct($client, $bucket, $prefix, $options);
parent::__construct($client, $bucket, $prefix, $visibility, $mimeTypeDetector, $options);
}

/**
Expand Down

0 comments on commit db33c6e

Please sign in to comment.