diff --git a/extend.php b/extend.php index e138007..29c88c0 100644 --- a/extend.php +++ b/extend.php @@ -3,7 +3,7 @@ /* * This file is part of blomstra/s3-assets. * - * Copyright (c) 2022 Blomstra Ltd. + * Copyright (c) FriendsOfFlarum * * For the full copyright and license information, please view the LICENSE.md * file that was distributed with this source code. @@ -11,8 +11,8 @@ namespace FoF\S3Assets; -use FoF\S3Assets\Extend\Drivers; use Flarum\Extend; +use FoF\S3Assets\Extend\Drivers; return [ (new Extend\Frontend('admin')) diff --git a/src/Console/MoveAssetsCommand.php b/src/Console/MoveAssetsCommand.php index 7d40cf9..33d7357 100644 --- a/src/Console/MoveAssetsCommand.php +++ b/src/Console/MoveAssetsCommand.php @@ -1,5 +1,14 @@ container = $container; @@ -78,13 +86,13 @@ protected function fire() // Move avatars $this->info('Moving avatars...'); - $this->moveFilesToDisk($localFilesystem, $this->paths->public . '/assets/avatars', $this->avatarDisk); + $this->moveFilesToDisk($localFilesystem, $this->paths->public.'/assets/avatars', $this->avatarDisk); // Move profile covers if (Arr::has($this->getFlarumDisks(), 'sycho-profile-cover')) { $this->info('Moving profile covers...'); $coversDisk = $this->factory->disk('sycho-profile-cover'); - $this->moveFilesToDisk($localFilesystem, $this->paths->public . '/assets/covers', $coversDisk); + $this->moveFilesToDisk($localFilesystem, $this->paths->public.'/assets/covers', $coversDisk); } $this->publishCommand->run( @@ -107,7 +115,7 @@ protected function moveFilesToDisk(Filesystem $localFilesystem, string $localPat { foreach ($localFilesystem->allFiles($localPath) as $file) { /** @var \Symfony\Component\Finder\SplFileInfo $file */ - $this->info('Moving ' . $file->getPathname()); + $this->info('Moving '.$file->getPathname()); $written = $disk->put($file->getRelativePathname(), $file->getContents()); if ($written) { diff --git a/src/Content/AdminPayload.php b/src/Content/AdminPayload.php index 54d1e04..97bb57d 100644 --- a/src/Content/AdminPayload.php +++ b/src/Content/AdminPayload.php @@ -1,5 +1,14 @@ make($this->config(), [ - 'driver' => 'required|in:s3', - 'key' => 'required|string', - 'secret' => 'required|string', - 'region' => 'required|string', - 'bucket' => 'required|string', - 'url' => 'url', - 'endpoint' => 'required|url', + 'driver' => 'required|in:s3', + 'key' => 'required|string', + 'secret' => 'required|string', + 'region' => 'required|string', + 'bucket' => 'required|string', + 'url' => 'url', + 'endpoint' => 'required|url', 'use_path_style_endpoint' => 'required|bool', - 'options.ACL' => 'required|string', - 'set_by_environment' => 'required|bool', + 'options.ACL' => 'required|string', + 'set_by_environment' => 'required|bool', ]); return $validator->passes(); @@ -33,9 +43,9 @@ public function config(): array $bucket = env('AWS_BUCKET', $this->settings->get('fof-upload.awsS3Bucket')); $region = env('AWS_DEFAULT_REGION', $this->settings->get('fof-upload.awsS3Region')); $cdnUrl = env('AWS_URL', $this->settings->get('fof-upload.cdnUrl')); - $pathStyle = (bool) (env('AWS_PATH_STYLE_ENDPOINT', $this->settings->get('fof-upload.awsS3UsePathStyleEndpoint'))); + $pathStyle = (bool) env('AWS_PATH_STYLE_ENDPOINT', $this->settings->get('fof-upload.awsS3UsePathStyleEndpoint')); - if (! $cdnUrl) { + if (!$cdnUrl) { $cdnUrl = sprintf('https://%s.s3.%s.amazonaws.com', $bucket, $region); $pathStyle = false; } @@ -43,18 +53,18 @@ public function config(): array $setByEnv = (env('AWS_ACCESS_KEY_ID') || env('AWS_SECRET_ACCESS_KEY') || env('AWS_ENDPOINT')); return [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID', $this->settings->get('fof-upload.awsS3Key')), - 'secret' => env('AWS_SECRET_ACCESS_KEY', $this->settings->get('fof-upload.awsS3Secret')), - 'region' => $region, - 'bucket' => $bucket, - 'url' => $cdnUrl, - 'endpoint' => env('AWS_ENDPOINT', $this->settings->get('fof-upload.awsS3Endpoint')), + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID', $this->settings->get('fof-upload.awsS3Key')), + 'secret' => env('AWS_SECRET_ACCESS_KEY', $this->settings->get('fof-upload.awsS3Secret')), + 'region' => $region, + 'bucket' => $bucket, + 'url' => $cdnUrl, + 'endpoint' => env('AWS_ENDPOINT', $this->settings->get('fof-upload.awsS3Endpoint')), 'use_path_style_endpoint' => $pathStyle, - 'set_by_environment' => $setByEnv, - 'options' => [ + 'set_by_environment' => $setByEnv, + 'options' => [ 'ACL' => env('AWS_ACL', $this->settings->get('fof-upload.awsS3ACL')), - ] + ], ]; } } diff --git a/src/Driver/S3Driver.php b/src/Driver/S3Driver.php index 964385b..010ac46 100644 --- a/src/Driver/S3Driver.php +++ b/src/Driver/S3Driver.php @@ -1,12 +1,21 @@ make(Config::class); - if (! $config->valid()) { + if (!$config->valid()) { return; } @@ -27,11 +36,11 @@ public function extend(Container $container, Extension $extension = null) ->driver('local', S3Driver::class) ->disk('flarum-assets', fn (Paths $paths, UrlGenerator $url) => [ 'root' => '/assets', - 'url' => $config->config()['url'] . '/assets' + 'url' => $config->config()['url'].'/assets', ]) ->disk('flarum-avatars', fn (Paths $paths, UrlGenerator $url) => [ 'root' => '/avatars', - 'url' => $config->config()['url'] . '/avatars' + 'url' => $config->config()['url'].'/avatars', ]) ->extend($container, $extension); } diff --git a/src/Frontend/Versioner.php b/src/Frontend/Versioner.php index 289d481..1a2459c 100644 --- a/src/Frontend/Versioner.php +++ b/src/Frontend/Versioner.php @@ -1,8 +1,16 @@