From 0e6e6e1223193f529ccc36491ab226f6a4c12c0a Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 11 Dec 2023 17:02:48 +0100 Subject: [PATCH] rename config file --- UPGRADING.md | 2 +- .../{medialibrary.php => media-library.php} | 0 .../Actions/PerformManipulationsAction.php | 2 +- src/Conversions/Conversion.php | 8 ++++---- src/Conversions/FileManipulator.php | 8 ++++---- src/Conversions/ImageGenerators/Image.php | 4 ++-- .../ImageGenerators/ImageGeneratorFactory.php | 2 +- src/Conversions/ImageGenerators/Video.php | 4 ++-- src/InteractsWithMedia.php | 6 +++--- .../Commands/CleanCommand.php | 4 ++-- .../Exceptions/FileIsTooBig.php | 2 +- src/MediaCollections/FileAdder.php | 20 +++++++++---------- src/MediaCollections/Filesystem.php | 6 +++--- src/MediaCollections/HtmlableMedia.php | 6 +++--- .../Models/Collections/MediaCollection.php | 2 +- .../Models/Observers/MediaObserver.php | 2 +- src/MediaLibraryServiceProvider.php | 12 +++++------ .../RegisteredResponsiveImages.php | 2 +- .../ResponsiveImageGenerator.php | 4 ++-- .../FileRemover/FileRemoverFactory.php | 2 +- src/Support/ImageFactory.php | 2 +- .../PathGenerator/DefaultPathGenerator.php | 2 +- .../PathGenerator/PathGeneratorFactory.php | 4 ++-- src/Support/TemporaryDirectory.php | 2 +- src/Support/UrlGenerator/BaseUrlGenerator.php | 2 +- .../UrlGenerator/UrlGeneratorFactory.php | 2 +- .../Conversions/Commands/CleanCommandTest.php | 6 +++--- tests/Conversions/ConversionFileNamerTest.php | 2 +- tests/Conversions/ConversionTest.php | 10 +++++----- .../Conversions/ImageGenerators/ImageTest.php | 4 ++-- tests/Conversions/ImageGenerators/SvgTest.php | 2 +- .../TestImageGeneratorWithConfigTest.php | 4 ++-- tests/Feature/FileAdder/IntegrationTest.php | 4 ++-- .../MediaConversions/AddMediaTest.php | 2 +- .../InteractsWithMedia/DeleteMediaTest.php | 2 +- tests/Feature/Media/CopyTest.php | 4 ++-- tests/Feature/Media/DeleteTest.php | 18 ++++++++--------- .../Media/GetPathRelativeToRootTest.php | 4 ++-- tests/Feature/Media/GetPathTest.php | 4 ++-- tests/Feature/Media/MediaRepositoryTest.php | 2 +- tests/Feature/Media/ToHtmlTest.php | 4 ++-- .../S3Integration/S3IntegrationTest.php | 4 ++-- tests/Image/ImageFactoryTest.php | 2 +- .../MediaCollections/MediaCollectionTest.php | 8 ++++---- .../ResponsiveImageFileNamerTest.php | 2 +- .../ResponsiveImageGeneratorFileNamerTest.php | 2 +- .../PathGenerator/BasePathGeneratorTest.php | 6 +++--- .../UrlGenerator/BaseUrlGeneratorTest.php | 4 ++-- 48 files changed, 106 insertions(+), 106 deletions(-) rename config/{medialibrary.php => media-library.php} (100%) diff --git a/UPGRADING.md b/UPGRADING.md index 03b498fc9..6e62f08ce 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,7 +4,7 @@ Because there are many breaking changes an upgrade is not that easy. There are m ## From v10 to v11 -- Rename to config file from `media-library.php` to `medialibrary.php`. +- Image v3 is now used. Make sure to update your image conversions to the new syntax. See [the image docs](https://spatie.be/docs/image/v3) for more info. - All event names have gained the `Event` suffix. For example `Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAdded` is now `Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent`. diff --git a/config/medialibrary.php b/config/media-library.php similarity index 100% rename from config/medialibrary.php rename to config/media-library.php diff --git a/src/Conversions/Actions/PerformManipulationsAction.php b/src/Conversions/Actions/PerformManipulationsAction.php index 2e5c10bfc..4c00bf482 100644 --- a/src/Conversions/Actions/PerformManipulationsAction.php +++ b/src/Conversions/Actions/PerformManipulationsAction.php @@ -29,7 +29,7 @@ public function execute( $conversion->format($media->extension); } - $image = Image::useImageDriver(config('medialibrary.image_driver')) + $image = Image::useImageDriver(config('media-library.image_driver')) ->loadFile($conversionTempFile) ->format('jpg'); diff --git a/src/Conversions/Conversion.php b/src/Conversions/Conversion.php index d0e209fab..cc61a480e 100644 --- a/src/Conversions/Conversion.php +++ b/src/Conversions/Conversion.php @@ -34,17 +34,17 @@ class Conversion public function __construct( protected string $name, ) { - $optimizerChain = OptimizerChainFactory::create(config('medialibrary.image_optimizers')); + $optimizerChain = OptimizerChainFactory::create(config('media-library.image_optimizers')); $this->manipulations = (new Manipulations()) ->optimize($optimizerChain) ->format('jpg'); - $this->fileNamer = app(config('medialibrary.file_namer')); + $this->fileNamer = app(config('media-library.file_namer')); - $this->loadingAttributeValue = config('medialibrary.default_loading_attribute_value'); + $this->loadingAttributeValue = config('media-library.default_loading_attribute_value'); - $this->performOnQueue = config('medialibrary.queue_conversions_by_default', true); + $this->performOnQueue = config('media-library.queue_conversions_by_default', true); } public static function create(string $name): self diff --git a/src/Conversions/FileManipulator.php b/src/Conversions/FileManipulator.php index e4590c8dd..840832215 100644 --- a/src/Conversions/FileManipulator.php +++ b/src/Conversions/FileManipulator.php @@ -92,8 +92,8 @@ protected function dispatchQueuedConversions( /** @var PerformConversionsJob $job */ $job = (new $performConversionsJobClass($conversions, $media, $onlyMissing)) - ->onConnection(config('medialibrary.queue_connection_name')) - ->onQueue(config('medialibrary.queue_name')); + ->onConnection(config('media-library.queue_connection_name')) + ->onQueue(config('media-library.queue_name')); dispatch($job); @@ -117,8 +117,8 @@ protected function generateResponsiveImages(Media $media, bool $withResponsiveIm /** @var GenerateResponsiveImagesJob $job */ $job = (new $generateResponsiveImagesJobClass($media)) - ->onConnection(config('medialibrary.queue_connection_name')) - ->onQueue(config('medialibrary.queue_name')); + ->onConnection(config('media-library.queue_connection_name')) + ->onQueue(config('media-library.queue_name')); dispatch($job); diff --git a/src/Conversions/ImageGenerators/Image.php b/src/Conversions/ImageGenerators/Image.php index 0dc71cb25..2b3add9c9 100644 --- a/src/Conversions/ImageGenerators/Image.php +++ b/src/Conversions/ImageGenerators/Image.php @@ -20,7 +20,7 @@ public function requirementsAreInstalled(): bool public function supportedExtensions(): Collection { $extensions = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif']; - if (config('medialibrary.image_driver') === 'imagick') { + if (config('media-library.image_driver') === 'imagick') { $extensions[] = 'tiff'; $extensions[] = 'heic'; $extensions[] = 'heif'; @@ -32,7 +32,7 @@ public function supportedExtensions(): Collection public function supportedMimeTypes(): Collection { $mimeTypes = ['image/jpeg', 'image/gif', 'image/png', 'image/webp', 'image/avif']; - if (config('medialibrary.image_driver') === 'imagick') { + if (config('media-library.image_driver') === 'imagick') { $mimeTypes[] = 'image/tiff'; $mimeTypes[] = 'image/heic'; $mimeTypes[] = 'image/heif'; diff --git a/src/Conversions/ImageGenerators/ImageGeneratorFactory.php b/src/Conversions/ImageGenerators/ImageGeneratorFactory.php index 6f604844f..a0adc600f 100644 --- a/src/Conversions/ImageGenerators/ImageGeneratorFactory.php +++ b/src/Conversions/ImageGenerators/ImageGeneratorFactory.php @@ -9,7 +9,7 @@ class ImageGeneratorFactory { public static function getImageGenerators(): Collection { - return collect(config('medialibrary.image_generators')) + return collect(config('media-library.image_generators')) ->map(function ($imageGeneratorClassName, $key) { $imageGeneratorConfig = []; diff --git a/src/Conversions/ImageGenerators/Video.php b/src/Conversions/ImageGenerators/Video.php index c1db84ae8..47d7c76c2 100644 --- a/src/Conversions/ImageGenerators/Video.php +++ b/src/Conversions/ImageGenerators/Video.php @@ -13,8 +13,8 @@ class Video extends ImageGenerator public function convert(string $file, ?Conversion $conversion = null): ?string { $ffmpeg = FFMpeg::create([ - 'ffmpeg.binaries' => config('medialibrary.ffmpeg_path'), - 'ffprobe.binaries' => config('medialibrary.ffprobe_path'), + 'ffmpeg.binaries' => config('media-library.ffmpeg_path'), + 'ffprobe.binaries' => config('media-library.ffprobe_path'), ]); $video = $ffmpeg->open($file); diff --git a/src/InteractsWithMedia.php b/src/InteractsWithMedia.php index fab4010df..a811c9f8f 100644 --- a/src/InteractsWithMedia.php +++ b/src/InteractsWithMedia.php @@ -58,7 +58,7 @@ public static function bootInteractsWithMedia() public function media(): MorphMany { - return $this->morphMany(config('medialibrary.media_model'), 'model'); + return $this->morphMany(config('media-library.media_model'), 'model'); } /** @@ -138,7 +138,7 @@ public function addMediaFromUrl(string $url, array|string ...$allowedMimeTypes): throw InvalidUrl::doesNotStartWithProtocol($url); } - $downloader = config('medialibrary.media_downloader', DefaultDownloader::class); + $downloader = config('media-library.media_downloader', DefaultDownloader::class); $temporaryFile = (new $downloader())->getTempFile($url); $this->guardAgainstInvalidMimeType($temporaryFile, $allowedMimeTypes); @@ -378,7 +378,7 @@ public function updateMedia(array $newMediaArray, string $collectionName = 'defa { $this->removeMediaItemsNotPresentInArray($newMediaArray, $collectionName); - $mediaClass = config('medialibrary.media_model'); + $mediaClass = config('media-library.media_model'); $mediaInstance = new $mediaClass(); $keyName = $mediaInstance->getKeyName(); diff --git a/src/MediaCollections/Commands/CleanCommand.php b/src/MediaCollections/Commands/CleanCommand.php index adb77c56a..48fa28304 100644 --- a/src/MediaCollections/Commands/CleanCommand.php +++ b/src/MediaCollections/Commands/CleanCommand.php @@ -181,12 +181,12 @@ protected function deleteDeprecatedResponsiveImages(Media $media): void protected function deleteOrphanedDirectories(): void { - $diskName = $this->argument('disk') ?: config('medialibrary.disk_name'); + $diskName = $this->argument('disk') ?: config('media-library.disk_name'); if (is_null(config("filesystems.disks.{$diskName}"))) { throw DiskDoesNotExist::create($diskName); } - $mediaClass = config('medialibrary.media_model'); + $mediaClass = config('media-library.media_model'); $mediaInstance = new $mediaClass(); $keyName = $mediaInstance->getKeyName(); diff --git a/src/MediaCollections/Exceptions/FileIsTooBig.php b/src/MediaCollections/Exceptions/FileIsTooBig.php index aa7ab6a8b..ecb1e1509 100644 --- a/src/MediaCollections/Exceptions/FileIsTooBig.php +++ b/src/MediaCollections/Exceptions/FileIsTooBig.php @@ -10,7 +10,7 @@ public static function create(string $path, ?int $size = null): self { $fileSize = File::getHumanReadableSize($size ?: filesize($path)); - $maxFileSize = File::getHumanReadableSize(config('medialibrary.max_file_size')); + $maxFileSize = File::getHumanReadableSize(config('media-library.max_file_size')); return new static("File `{$path}` has a size of {$fileSize} which is greater than the maximum allowed {$maxFileSize}"); } diff --git a/src/MediaCollections/FileAdder.php b/src/MediaCollections/FileAdder.php index 3280a4673..1e4d2e028 100644 --- a/src/MediaCollections/FileAdder.php +++ b/src/MediaCollections/FileAdder.php @@ -240,18 +240,18 @@ public function toMediaCollectionFromRemote(string $collectionName = 'default', $this->fileSize ??= $storage->size($this->pathToFile); - if ($this->fileSize > config('medialibrary.max_file_size')) { + if ($this->fileSize > config('media-library.max_file_size')) { throw FileIsTooBig::create($this->pathToFile, $storage->size($this->pathToFile)); } - $mediaClass = config('medialibrary.media_model'); + $mediaClass = config('media-library.media_model'); /** @var Media $media */ $media = new $mediaClass(); $media->name = $this->mediaName; $sanitizedFileName = ($this->fileNameSanitizer)($this->fileName); - $fileName = app(config('medialibrary.file_namer'))->originalFileName($sanitizedFileName); + $fileName = app(config('media-library.file_namer'))->originalFileName($sanitizedFileName); $this->fileName = $this->appendExtension($fileName, pathinfo($sanitizedFileName, PATHINFO_EXTENSION)); $media->file_name = $this->fileName; @@ -286,7 +286,7 @@ public function toMediaCollectionFromRemote(string $collectionName = 'default', public function toMediaCollection(string $collectionName = 'default', string $diskName = ''): Media { $sanitizedFileName = ($this->fileNameSanitizer)($this->fileName); - $fileName = app(config('medialibrary.file_namer'))->originalFileName($sanitizedFileName); + $fileName = app(config('media-library.file_namer'))->originalFileName($sanitizedFileName); $this->fileName = $this->appendExtension($fileName, pathinfo($sanitizedFileName, PATHINFO_EXTENSION)); if ($this->file instanceof RemoteFile) { @@ -303,11 +303,11 @@ public function toMediaCollection(string $collectionName = 'default', string $di $this->fileSize ??= filesize($this->pathToFile); - if ($this->fileSize > config('medialibrary.max_file_size')) { + if ($this->fileSize > config('media-library.max_file_size')) { throw FileIsTooBig::create($this->pathToFile); } - $mediaClass = config('medialibrary.media_model'); + $mediaClass = config('media-library.media_model'); /** @var Media $media */ $media = new $mediaClass(); @@ -367,7 +367,7 @@ protected function determineDiskName(string $diskName, string $collectionName): } } - return config('medialibrary.disk_name'); + return config('media-library.disk_name'); } protected function determineConversionsDiskName(string $originalsDiskName, string $collectionName): string @@ -460,15 +460,15 @@ protected function processMediaItem(HasMedia $model, Media $media, self $fileAdd } if ($this->generateResponsiveImages && (new ImageGenerator())->canConvert($media)) { - $generateResponsiveImagesJobClass = config('medialibrary.jobs.generate_responsive_images', GenerateResponsiveImagesJob::class); + $generateResponsiveImagesJobClass = config('media-library.jobs.generate_responsive_images', GenerateResponsiveImagesJob::class); $job = new $generateResponsiveImagesJobClass($media); - if ($customConnection = config('medialibrary.queue_connection_name')) { + if ($customConnection = config('media-library.queue_connection_name')) { $job->onConnection($customConnection); } - if ($customQueue = config('medialibrary.queue_name')) { + if ($customQueue = config('media-library.queue_name')) { $job->onQueue($customQueue); } diff --git a/src/MediaCollections/Filesystem.php b/src/MediaCollections/Filesystem.php index dd12f538f..be3f3f2f6 100644 --- a/src/MediaCollections/Filesystem.php +++ b/src/MediaCollections/Filesystem.php @@ -107,7 +107,7 @@ protected function shouldCopyFileOnDisk(RemoteFile $file, Media $media, string $ return false; } - if ((is_countable(config('medialibrary.remote.extra_headers')) ? count(config('medialibrary.remote.extra_headers')) : 0) > 0) { + if ((is_countable(config('media-library.remote.extra_headers')) ? count(config('media-library.remote.extra_headers')) : 0) > 0) { return false; } @@ -189,7 +189,7 @@ public function getRemoteHeadersForFile( ): array { $mimeTypeHeader = ['ContentType' => $mimeType ?: File::getMimeType($file)]; - $extraHeaders = config('medialibrary.remote.extra_headers'); + $extraHeaders = config('media-library.remote.extra_headers'); return array_merge( $mimeTypeHeader, @@ -277,7 +277,7 @@ protected function renameMediaFile(Media $media): void protected function renameConversionFiles(Media $media): void { - $mediaWithOldFileName = config('medialibrary.media_model')::find($media->id); + $mediaWithOldFileName = config('media-library.media_model')::find($media->id); $mediaWithOldFileName->file_name = $mediaWithOldFileName->getOriginal('file_name'); $conversionDirectory = $this->getConversionDirectory($media); diff --git a/src/MediaCollections/HtmlableMedia.php b/src/MediaCollections/HtmlableMedia.php index a701ac8ba..e6e849854 100644 --- a/src/MediaCollections/HtmlableMedia.php +++ b/src/MediaCollections/HtmlableMedia.php @@ -57,7 +57,7 @@ public function toHtml() $attributeString = ' '.$attributeString; } - $loadingAttributeValue = config('medialibrary.default_loading_attribute_value'); + $loadingAttributeValue = config('media-library.default_loading_attribute_value'); if ($this->conversionName !== '') { $conversionObject = ConversionCollection::createForMedia($this->media)->getByName($this->conversionName); @@ -74,7 +74,7 @@ public function toHtml() $height = ''; if ($this->media->hasResponsiveImages($this->conversionName)) { - $viewName = config('medialibrary.responsive_images.use_tiny_placeholders') + $viewName = config('media-library.responsive_images.use_tiny_placeholders') ? 'responsiveImageWithPlaceholder' : 'responsiveImage'; @@ -87,7 +87,7 @@ public function toHtml() $media = $this->media; $conversion = $this->conversionName; - return view("medialibrary::{$viewName}", compact( + return view("media-library::{$viewName}", compact( 'media', 'conversion', 'attributeString', diff --git a/src/MediaCollections/Models/Collections/MediaCollection.php b/src/MediaCollections/Models/Collections/MediaCollection.php index 22e4072b2..85ab765ea 100644 --- a/src/MediaCollections/Models/Collections/MediaCollection.php +++ b/src/MediaCollections/Models/Collections/MediaCollection.php @@ -56,7 +56,7 @@ public function toHtml() public function jsonSerialize(): array { - if (config('medialibrary.use_default_collection_serialization')) { + if (config('media-library.use_default_collection_serialization')) { return parent::jsonSerialize(); } diff --git a/src/MediaCollections/Models/Observers/MediaObserver.php b/src/MediaCollections/Models/Observers/MediaObserver.php index 21b7b7557..b3cd38440 100644 --- a/src/MediaCollections/Models/Observers/MediaObserver.php +++ b/src/MediaCollections/Models/Observers/MediaObserver.php @@ -22,7 +22,7 @@ public function updating(Media $media) /** @var Filesystem $filesystem */ $filesystem = app(Filesystem::class); - if (config('medialibrary.moves_media_on_update')) { + if (config('media-library.moves_media_on_update')) { $filesystem->syncMediaPath($media); } diff --git a/src/MediaLibraryServiceProvider.php b/src/MediaLibraryServiceProvider.php index 400aef6b0..30842c1cb 100644 --- a/src/MediaLibraryServiceProvider.php +++ b/src/MediaLibraryServiceProvider.php @@ -19,9 +19,9 @@ public function configurePackage(Package $package): void { $package ->name('laravel-medialibrary') - ->hasConfigFile() + ->hasConfigFile('media-library') ->hasMigration('create_media_table') - ->hasViews() + ->hasViews('media-library') ->hasCommands([ RegenerateCommand::class, ClearCommand::class, @@ -31,18 +31,18 @@ public function configurePackage(Package $package): void public function packageBooted() { - $mediaClass = config('medialibrary.media_model', Media::class); + $mediaClass = config('media-library.media_model', Media::class); $mediaClass::observe(new MediaObserver()); } public function packageRegistered() { - $this->app->bind(WidthCalculator::class, config('medialibrary.responsive_images.width_calculator')); - $this->app->bind(TinyPlaceholderGenerator::class, config('medialibrary.responsive_images.tiny_placeholder_generator')); + $this->app->bind(WidthCalculator::class, config('media-library.responsive_images.width_calculator')); + $this->app->bind(TinyPlaceholderGenerator::class, config('media-library.responsive_images.tiny_placeholder_generator')); $this->app->scoped(MediaRepository::class, function () { - $mediaClass = config('medialibrary.media_model'); + $mediaClass = config('media-library.media_model'); return new MediaRepository(new $mediaClass()); }); diff --git a/src/ResponsiveImages/RegisteredResponsiveImages.php b/src/ResponsiveImages/RegisteredResponsiveImages.php index c6e71b2ef..641cbefa2 100644 --- a/src/ResponsiveImages/RegisteredResponsiveImages.php +++ b/src/ResponsiveImages/RegisteredResponsiveImages.php @@ -36,7 +36,7 @@ public function getSrcset(): string ->map(fn (ResponsiveImage $responsiveImage) => "{$responsiveImage->url()} {$responsiveImage->width()}w") ->implode(', '); - $shouldAddPlaceholderSvg = config('medialibrary.responsive_images.use_tiny_placeholders') + $shouldAddPlaceholderSvg = config('media-library.responsive_images.use_tiny_placeholders') && $this->getPlaceholderSvg(); if ($shouldAddPlaceholderSvg) { diff --git a/src/ResponsiveImages/ResponsiveImageGenerator.php b/src/ResponsiveImages/ResponsiveImageGenerator.php index ef49aee5d..8560377ab 100644 --- a/src/ResponsiveImages/ResponsiveImageGenerator.php +++ b/src/ResponsiveImages/ResponsiveImageGenerator.php @@ -27,7 +27,7 @@ public function __construct( protected WidthCalculator $widthCalculator, protected TinyPlaceholderGenerator $tinyPlaceholderGenerator ) { - $this->fileNamer = app(config('medialibrary.file_namer')); + $this->fileNamer = app(config('media-library.file_namer')); } public function generateResponsiveImages(Media $media): void @@ -133,7 +133,7 @@ public function generateTinyJpg( $originalImageHeight = $originalImage->getHeight(); - $svg = view('medialibrary::placeholderSvg', compact( + $svg = view('media-library::placeholderSvg', compact( 'originalImageWidth', 'originalImageHeight', 'tinyImageBase64' diff --git a/src/Support/FileRemover/FileRemoverFactory.php b/src/Support/FileRemover/FileRemoverFactory.php index c5faa2a60..336804f05 100644 --- a/src/Support/FileRemover/FileRemoverFactory.php +++ b/src/Support/FileRemover/FileRemoverFactory.php @@ -9,7 +9,7 @@ class FileRemoverFactory { public static function create(Media $media): FileRemover { - $fileRemoverClass = config('medialibrary.file_remover_class'); + $fileRemoverClass = config('media-library.file_remover_class'); static::guardAgainstInvalidFileRemover($fileRemoverClass); diff --git a/src/Support/ImageFactory.php b/src/Support/ImageFactory.php index 23c68e3d4..b943fbaa3 100644 --- a/src/Support/ImageFactory.php +++ b/src/Support/ImageFactory.php @@ -9,7 +9,7 @@ class ImageFactory { public static function load(string $path): ImageDriver { - return Image::useImageDriver(config('medialibrary.image_driver')) + return Image::useImageDriver(config('media-library.image_driver')) ->loadFile($path); } } diff --git a/src/Support/PathGenerator/DefaultPathGenerator.php b/src/Support/PathGenerator/DefaultPathGenerator.php index dbb9ac111..0e6d1401d 100644 --- a/src/Support/PathGenerator/DefaultPathGenerator.php +++ b/src/Support/PathGenerator/DefaultPathGenerator.php @@ -35,7 +35,7 @@ public function getPathForResponsiveImages(Media $media): string */ protected function getBasePath(Media $media): string { - $prefix = config('medialibrary.prefix', ''); + $prefix = config('media-library.prefix', ''); if ($prefix !== '') { return $prefix.'/'.$media->getKey(); diff --git a/src/Support/PathGenerator/PathGeneratorFactory.php b/src/Support/PathGenerator/PathGeneratorFactory.php index 18f71b97f..f59a61156 100644 --- a/src/Support/PathGenerator/PathGeneratorFactory.php +++ b/src/Support/PathGenerator/PathGeneratorFactory.php @@ -19,9 +19,9 @@ public static function create(Media $media): PathGenerator protected static function getPathGeneratorClass(Media $media) { - $defaultPathGeneratorClass = config('medialibrary.path_generator'); + $defaultPathGeneratorClass = config('media-library.path_generator'); - foreach (config('medialibrary.custom_path_generators', []) as $modelClass => $customPathGeneratorClass) { + foreach (config('media-library.custom_path_generators', []) as $modelClass => $customPathGeneratorClass) { if (static::mediaBelongToModelClass($media, $modelClass)) { return $customPathGeneratorClass; } diff --git a/src/Support/TemporaryDirectory.php b/src/Support/TemporaryDirectory.php index 757410f0c..a7d53e422 100644 --- a/src/Support/TemporaryDirectory.php +++ b/src/Support/TemporaryDirectory.php @@ -14,7 +14,7 @@ public static function create(): BaseTemporaryDirectory protected static function getTemporaryDirectoryPath(): string { - $path = config('medialibrary.temporary_directory_path') ?? storage_path('media-library/temp'); + $path = config('media-library.temporary_directory_path') ?? storage_path('media-library/temp'); return $path.DIRECTORY_SEPARATOR.Str::random(32); } diff --git a/src/Support/UrlGenerator/BaseUrlGenerator.php b/src/Support/UrlGenerator/BaseUrlGenerator.php index 2d1bdc936..c4c894fd4 100644 --- a/src/Support/UrlGenerator/BaseUrlGenerator.php +++ b/src/Support/UrlGenerator/BaseUrlGenerator.php @@ -66,7 +66,7 @@ protected function getDisk(): Filesystem public function versionUrl(string $path = ''): string { - if (! $this->config->get('medialibrary.version_urls')) { + if (! $this->config->get('media-library.version_urls')) { return $path; } diff --git a/src/Support/UrlGenerator/UrlGeneratorFactory.php b/src/Support/UrlGenerator/UrlGeneratorFactory.php index dfffd1f28..77d4ae3a4 100644 --- a/src/Support/UrlGenerator/UrlGeneratorFactory.php +++ b/src/Support/UrlGenerator/UrlGeneratorFactory.php @@ -11,7 +11,7 @@ class UrlGeneratorFactory { public static function createForMedia(Media $media, string $conversionName = ''): UrlGenerator { - $urlGeneratorClass = config('medialibrary.url_generator'); + $urlGeneratorClass = config('media-library.url_generator'); static::guardAgainstInvalidUrlGenerator($urlGeneratorClass); diff --git a/tests/Conversions/Commands/CleanCommandTest.php b/tests/Conversions/Commands/CleanCommandTest.php index ddd3ddedc..11c526c4d 100644 --- a/tests/Conversions/Commands/CleanCommandTest.php +++ b/tests/Conversions/Commands/CleanCommandTest.php @@ -211,7 +211,7 @@ it('will throw an exception when using a non existing disk', function () { $this->expectException(DiskDoesNotExist::class); - config(['medialibrary.disk_name' => 'diskdoesnotexist']); + config(['media-library.disk_name' => 'diskdoesnotexist']); $this->artisan('media-library:clean') ->assertExitCode(1); @@ -226,7 +226,7 @@ $this->urlGenerator->setPathGenerator($this->pathGenerator); - config()->set('medialibrary.custom_path_generators', [ + config()->set('media-library.custom_path_generators', [ TestModelWithConversion::class => CustomPathGenerator::class, ]); @@ -255,7 +255,7 @@ $this->urlGenerator->setPathGenerator($this->pathGenerator); - config()->set('medialibrary.custom_path_generators', [ + config()->set('media-library.custom_path_generators', [ TestModelWithConversion::class => TestPathGeneratorConversionsInOriginalImageDirectory::class, ]); diff --git a/tests/Conversions/ConversionFileNamerTest.php b/tests/Conversions/ConversionFileNamerTest.php index e7119f749..8003e863f 100644 --- a/tests/Conversions/ConversionFileNamerTest.php +++ b/tests/Conversions/ConversionFileNamerTest.php @@ -5,7 +5,7 @@ it('can use a custom file namer', function () { $fileName = 'prefix_test_suffix'; - config()->set('medialibrary.file_namer', TestFileNamer::class); + config()->set('media-library.file_namer', TestFileNamer::class); $this ->testModelWithConversion diff --git a/tests/Conversions/ConversionTest.php b/tests/Conversions/ConversionTest.php index 78b09283f..34b2cb835 100644 --- a/tests/Conversions/ConversionTest.php +++ b/tests/Conversions/ConversionTest.php @@ -45,27 +45,27 @@ }); it('will be queued without config', function () { - config()->set('medialibrary.queue_conversions_by_default', null); + config()->set('media-library.queue_conversions_by_default', null); expect($this->conversion->shouldBeQueued())->toBeTrue(); }); it('will be queued by default', function () { - config()->set('medialibrary.queue_conversions_by_default', true); + config()->set('media-library.queue_conversions_by_default', true); expect($this->conversion->shouldBeQueued())->toBeTrue(); }); it('will be non queued by default', function () { - config()->set('medialibrary.queue_conversions_by_default', false); + config()->set('media-library.queue_conversions_by_default', false); expect($this->conversion->shouldBeQueued())->toBeTrue(); }); it('can be set to queued', function () { - config()->set('medialibrary.queue_conversions_by_default', false); + config()->set('media-library.queue_conversions_by_default', false); expect($this->conversion->queued()->shouldBeQueued())->toBeTrue(); }); it('can be set to non queued', function () { - config()->set('medialibrary.queue_conversions_by_default', true); + config()->set('media-library.queue_conversions_by_default', true); expect($this->conversion->nonQueued()->shouldBeQueued())->toBeFalse(); }); diff --git a/tests/Conversions/ImageGenerators/ImageTest.php b/tests/Conversions/ImageGenerators/ImageTest.php index d778f8604..f39becdd8 100644 --- a/tests/Conversions/ImageGenerators/ImageTest.php +++ b/tests/Conversions/ImageGenerators/ImageTest.php @@ -19,7 +19,7 @@ 'can convert a tiff image', function () { //TIFF format requires imagick - config(['medialibrary.image_driver' => 'imagick']); + config(['media-library.image_driver' => 'imagick']); $imageGenerator = new Image(); @@ -38,7 +38,7 @@ function () { 'can convert a heic image', function () { //heic format requires imagick - config(['medialibrary.image_driver' => 'imagick']); + config(['media-library.image_driver' => 'imagick']); $imageGenerator = new Image(); diff --git a/tests/Conversions/ImageGenerators/SvgTest.php b/tests/Conversions/ImageGenerators/SvgTest.php index 7767ebdac..660afb0d3 100644 --- a/tests/Conversions/ImageGenerators/SvgTest.php +++ b/tests/Conversions/ImageGenerators/SvgTest.php @@ -3,7 +3,7 @@ use Spatie\MediaLibrary\Conversions\ImageGenerators\Svg; it('can convert a svg', function () { - config()->set('medialibrary.image_driver', 'imagick'); + config()->set('media-library.image_driver', 'imagick'); $imageGenerator = new Svg(); diff --git a/tests/Conversions/ImageGenerators/TestImageGeneratorWithConfigTest.php b/tests/Conversions/ImageGenerators/TestImageGeneratorWithConfigTest.php index 637a6c4b8..73f7fdaed 100644 --- a/tests/Conversions/ImageGenerators/TestImageGeneratorWithConfigTest.php +++ b/tests/Conversions/ImageGenerators/TestImageGeneratorWithConfigTest.php @@ -4,7 +4,7 @@ use Spatie\MediaLibrary\Tests\TestSupport\TestImageGeneratorWithConfig; test('image generators can get parameter from the config file', function () { - config()->set('medialibrary.image_generators', [ + config()->set('media-library.image_generators', [ TestImageGeneratorWithConfig::class => ['firstName' => 'firstValue', 'secondName' => 'secondValue'], ]); @@ -19,7 +19,7 @@ }); test('image generators will receive config parameters by name', function () { - config()->set('medialibrary.image_generators', [ + config()->set('media-library.image_generators', [ TestImageGeneratorWithConfig::class => ['secondName' => 'secondValue', 'firstName' => 'firstValue'], ]); diff --git a/tests/Feature/FileAdder/IntegrationTest.php b/tests/Feature/FileAdder/IntegrationTest.php index 6e70ada13..110de499c 100644 --- a/tests/Feature/FileAdder/IntegrationTest.php +++ b/tests/Feature/FileAdder/IntegrationTest.php @@ -379,7 +379,7 @@ }); test('the file name can be modified using a file namer', function () { - config()->set('medialibrary.file_namer', RenameOriginalFileNamer::class); + config()->set('media-library.file_namer', RenameOriginalFileNamer::class); $media = $this->testModel ->addMedia($this->getTestJpg()) @@ -470,7 +470,7 @@ }); it('will throw an exception when adding a file that is too big', function () { - config()->set('medialibrary.max_file_size', 1); + config()->set('media-library.max_file_size', 1); $this->expectException(FileIsTooBig::class); diff --git a/tests/Feature/FileAdder/MediaConversions/AddMediaTest.php b/tests/Feature/FileAdder/MediaConversions/AddMediaTest.php index 7555a693c..9a33996f9 100644 --- a/tests/Feature/FileAdder/MediaConversions/AddMediaTest.php +++ b/tests/Feature/FileAdder/MediaConversions/AddMediaTest.php @@ -67,7 +67,7 @@ public function registerMediaConversions(?Media $media = null): void }); it('can create a derived version of a pdf if imagick exists', function () { - config()->set('medialibrary.image_driver', 'imagick'); + config()->set('media-library.image_driver', 'imagick'); $media = $this->testModelWithConversion ->addMedia($this->getTestFilesDirectory('test.pdf')) diff --git a/tests/Feature/InteractsWithMedia/DeleteMediaTest.php b/tests/Feature/InteractsWithMedia/DeleteMediaTest.php index defaf4c82..6817a6fcc 100644 --- a/tests/Feature/InteractsWithMedia/DeleteMediaTest.php +++ b/tests/Feature/InteractsWithMedia/DeleteMediaTest.php @@ -47,7 +47,7 @@ }); it('will remove the files when using a custom model and deleting it', function () { - config()->set('medialibrary.media_model', TestCustomMediaModel::class); + config()->set('media-library.media_model', TestCustomMediaModel::class); (new MediaLibraryServiceProvider(app()))->register()->boot(); diff --git a/tests/Feature/Media/CopyTest.php b/tests/Feature/Media/CopyTest.php index 7dd8bad27..49580c0a8 100644 --- a/tests/Feature/Media/CopyTest.php +++ b/tests/Feature/Media/CopyTest.php @@ -36,7 +36,7 @@ mkdir(storage_path('media-library/temp'), 0777, true); } - config(['medialibrary.temporary_directory_path' => realpath(storage_path('media-library/temp'))]); + config(['media-library.temporary_directory_path' => realpath(storage_path('media-library/temp'))]); /** @var TestModel $model */ $model = TestModel::create(['name' => 'test']); @@ -104,7 +104,7 @@ mkdir(storage_path('media-library/temp'), 0777, true); } - config(['medialibrary.temporary_directory_path' => realpath(storage_path('media-library/temp'))]); + config(['media-library.temporary_directory_path' => realpath(storage_path('media-library/temp'))]); /** @var TestModel $model */ $model = TestModel::create(['name' => 'test']); diff --git a/tests/Feature/Media/DeleteTest.php b/tests/Feature/Media/DeleteTest.php index 2de838661..7588a084c 100644 --- a/tests/Feature/Media/DeleteTest.php +++ b/tests/Feature/Media/DeleteTest.php @@ -30,7 +30,7 @@ }); it('will remove files when deleting a media object with a custom path generator', function () { - config(['medialibrary.path_generator' => TestPathGenerator::class]); + config(['media-library.path_generator' => TestPathGenerator::class]); $pathGenerator = new TestPathGenerator(); @@ -45,8 +45,8 @@ }); it('will remove files when deleting a media object with a custom path and directory generator', function () { - config(['medialibrary.path_generator' => CustomDirectoryStructurePathGenerator::class]); - config(['medialibrary.file_remover_class' => FileBaseFileRemover::class]); + config(['media-library.path_generator' => CustomDirectoryStructurePathGenerator::class]); + config(['media-library.file_remover_class' => FileBaseFileRemover::class]); $pathGenerator = new CustomDirectoryStructurePathGenerator(); @@ -61,8 +61,8 @@ }); it('will remove converted files when deleting a media object with a custom path and directory generator and custom removal class', function () { - config(['medialibrary.path_generator' => CustomDirectoryStructurePathGenerator::class]); - config(['medialibrary.file_remover_class' => FileBaseFileRemover::class]); + config(['media-library.path_generator' => CustomDirectoryStructurePathGenerator::class]); + config(['media-library.file_remover_class' => FileBaseFileRemover::class]); $pathGenerator = new CustomDirectoryStructurePathGenerator(); @@ -80,8 +80,8 @@ }); it('will remove converted files and responsive images when deleting a media object with a custom path and directory generator and custom removal class', function () { - config(['medialibrary.path_generator' => CustomDirectoryStructurePathGenerator::class]); - config(['medialibrary.file_remover_class' => FileBaseFileRemover::class]); + config(['media-library.path_generator' => CustomDirectoryStructurePathGenerator::class]); + config(['media-library.file_remover_class' => FileBaseFileRemover::class]); $media = $this->testModelWithConversionsOnOtherDisk->addMedia($this->getTestPng())->toMediaCollection('images'); $pathGenerator = new CustomDirectoryStructurePathGenerator(); @@ -97,8 +97,8 @@ }); it('will NOT remove other files within the same folder when deleting a media object with a custom path and directory generator', function () { - config(['medialibrary.path_generator' => CustomDirectoryStructurePathGenerator::class]); - config(['medialibrary.file_remover_class' => FileBaseFileRemover::class]); + config(['media-library.path_generator' => CustomDirectoryStructurePathGenerator::class]); + config(['media-library.file_remover_class' => FileBaseFileRemover::class]); $media = $this->testModel->addMedia($this->getTestJpg())->toMediaCollection('images'); $media2 = $this->testModel->addMedia($this->getTestPng())->toMediaCollection('images'); diff --git a/tests/Feature/Media/GetPathRelativeToRootTest.php b/tests/Feature/Media/GetPathRelativeToRootTest.php index 864d4e0ae..4fe9ff5b2 100644 --- a/tests/Feature/Media/GetPathRelativeToRootTest.php +++ b/tests/Feature/Media/GetPathRelativeToRootTest.php @@ -33,7 +33,7 @@ }); it('can get a path of an original item with prefix relative to the filesystem\'s root', function () { - config(['medialibrary.prefix' => 'prefix']); + config(['media-library.prefix' => 'prefix']); $media = $this->testModel->addMedia($this->getTestJpg())->toMediaCollection(); @@ -45,7 +45,7 @@ }); it('can get a path of a derived image with prefix relative to the filesystem\'s root', function () { - config(['medialibrary.prefix' => 'prefix']); + config(['media-library.prefix' => 'prefix']); $media = $this->testModelWithConversion->addMedia($this->getTestJpg())->toMediaCollection(); diff --git a/tests/Feature/Media/GetPathTest.php b/tests/Feature/Media/GetPathTest.php index ff7c94c14..1de1e417f 100644 --- a/tests/Feature/Media/GetPathTest.php +++ b/tests/Feature/Media/GetPathTest.php @@ -33,7 +33,7 @@ }); it('can get a path of an original item with prefix', function () { - config(['medialibrary.prefix' => 'prefix']); + config(['media-library.prefix' => 'prefix']); $media = $this->testModel->addMedia($this->getTestJpg())->toMediaCollection(); @@ -45,7 +45,7 @@ }); it('can get a path of a derived image with prefix', function () { - config(['medialibrary.prefix' => 'prefix']); + config(['media-library.prefix' => 'prefix']); $media = $this->testModelWithConversion->addMedia($this->getTestJpg())->toMediaCollection(); diff --git a/tests/Feature/Media/MediaRepositoryTest.php b/tests/Feature/Media/MediaRepositoryTest.php index 8214c2760..782858666 100644 --- a/tests/Feature/Media/MediaRepositoryTest.php +++ b/tests/Feature/Media/MediaRepositoryTest.php @@ -4,7 +4,7 @@ use Spatie\MediaLibrary\Tests\TestSupport\TestModels\TestCustomMediaModel; it('can use a custom media model', function () { - config()->set('medialibrary.media_model', TestCustomMediaModel::class); + config()->set('media-library.media_model', TestCustomMediaModel::class); $this->testModel ->addMedia($this->getTestJpg()) diff --git a/tests/Feature/Media/ToHtmlTest.php b/tests/Feature/Media/ToHtmlTest.php index db403bd08..c73a68b44 100644 --- a/tests/Feature/Media/ToHtmlTest.php +++ b/tests/Feature/Media/ToHtmlTest.php @@ -55,7 +55,7 @@ }); it('can render pdf thumbnail as an image', function () { - config()->set('medialibrary.image_driver', 'imagick'); + config()->set('media-library.image_driver', 'imagick'); $media = $this->testModelWithConversion ->addMedia($this->getTestPdf()) @@ -91,7 +91,7 @@ }); it('will not render extra javascript or include base64 svg when tiny placeholders are turned off', function () { - config()->set('medialibrary.responsive_images.use_tiny_placeholders', false); + config()->set('media-library.responsive_images.use_tiny_placeholders', false); $media = $this->testModelWithConversion ->addMedia($this->getTestJpg()) diff --git a/tests/Feature/S3Integration/S3IntegrationTest.php b/tests/Feature/S3Integration/S3IntegrationTest.php index 17995798b..ef6bd2e2b 100644 --- a/tests/Feature/S3Integration/S3IntegrationTest.php +++ b/tests/Feature/S3Integration/S3IntegrationTest.php @@ -13,13 +13,13 @@ $this->s3BaseDirectory = getS3BaseTestDirectory(); - config()->set('medialibrary.path_generator', S3TestPathGenerator::class); + config()->set('media-library.path_generator', S3TestPathGenerator::class); }); afterEach(function () { cleanUpS3(); - config()->set('medialibrary.path_generator', null); + config()->set('media-library.path_generator', null); }); it('can add media from a disk to s3', function () { diff --git a/tests/Image/ImageFactoryTest.php b/tests/Image/ImageFactoryTest.php index 10eebd11b..4a4cba189 100644 --- a/tests/Image/ImageFactoryTest.php +++ b/tests/Image/ImageFactoryTest.php @@ -3,7 +3,7 @@ use Spatie\MediaLibrary\Support\ImageFactory; test('loading an image uses the correct driver', function () { - config(['medialibrary.image_driver' => 'imagick']); + config(['media-library.image_driver' => 'imagick']); $image = ImageFactory::load($this->getTestJpg()); diff --git a/tests/MediaCollections/MediaCollectionTest.php b/tests/MediaCollections/MediaCollectionTest.php index fd93ead79..a1059b7a9 100644 --- a/tests/MediaCollections/MediaCollectionTest.php +++ b/tests/MediaCollections/MediaCollectionTest.php @@ -39,8 +39,8 @@ it('doesnt move media on change', function () { config([ - 'medialibrary.path_generator' => TestUuidPathGenerator::class, - 'medialibrary.moves_media_on_update' => false, + 'media-library.path_generator' => TestUuidPathGenerator::class, + 'media-library.moves_media_on_update' => false, ]); $mediaItem = $this @@ -62,8 +62,8 @@ it('moves media on change', function () { config([ - 'medialibrary.path_generator' => TestUuidPathGenerator::class, - 'medialibrary.moves_media_on_update' => true, + 'media-library.path_generator' => TestUuidPathGenerator::class, + 'media-library.moves_media_on_update' => true, ]); $mediaItem = $this diff --git a/tests/ResponsiveImages/ResponsiveImageFileNamerTest.php b/tests/ResponsiveImages/ResponsiveImageFileNamerTest.php index d74567b9b..39d209551 100644 --- a/tests/ResponsiveImages/ResponsiveImageFileNamerTest.php +++ b/tests/ResponsiveImages/ResponsiveImageFileNamerTest.php @@ -3,7 +3,7 @@ use Spatie\MediaLibrary\Tests\TestSupport\TestFileNamer; beforeEach(function () { - config()->set('medialibrary.file_namer', TestFileNamer::class); + config()->set('media-library.file_namer', TestFileNamer::class); $this->fileName = 'prefix_test_suffix'; $this->fileNameWithUnderscore = 'prefix_test__suffix'; diff --git a/tests/ResponsiveImages/ResponsiveImageGeneratorFileNamerTest.php b/tests/ResponsiveImages/ResponsiveImageGeneratorFileNamerTest.php index e59114ddd..5d11ced1c 100644 --- a/tests/ResponsiveImages/ResponsiveImageGeneratorFileNamerTest.php +++ b/tests/ResponsiveImages/ResponsiveImageGeneratorFileNamerTest.php @@ -3,7 +3,7 @@ use Spatie\MediaLibrary\Tests\TestSupport\TestFileNamer; beforeEach(function () { - config()->set('medialibrary.file_namer', TestFileNamer::class); + config()->set('media-library.file_namer', TestFileNamer::class); $this->fileName = 'prefix_test_suffix'; }); diff --git a/tests/Support/PathGenerator/BasePathGeneratorTest.php b/tests/Support/PathGenerator/BasePathGeneratorTest.php index 051b1db6d..b05de650c 100644 --- a/tests/Support/PathGenerator/BasePathGeneratorTest.php +++ b/tests/Support/PathGenerator/BasePathGeneratorTest.php @@ -40,7 +40,7 @@ }); it('can use a custom path generator on the model', function () { - config()->set('medialibrary.custom_path_generators', [ + config()->set('media-library.custom_path_generators', [ TestModelWithConversion::class => CustomPathGenerator::class, ]); @@ -52,7 +52,7 @@ }); it('can use a custom path generator on a morph map model', function () { - config()->set('medialibrary.custom_path_generators', [ + config()->set('media-library.custom_path_generators', [ 'test-model-with-morph-map' => CustomPathGenerator::class, ]); @@ -64,7 +64,7 @@ }); it('can use a custom path generator on a morph map model via class', function () { - config()->set('medialibrary.custom_path_generators', [ + config()->set('media-library.custom_path_generators', [ TestModelWithMorphMap::class => CustomPathGenerator::class, ]); diff --git a/tests/Support/UrlGenerator/BaseUrlGeneratorTest.php b/tests/Support/UrlGenerator/BaseUrlGeneratorTest.php index 6e983f5a3..48dccc108 100644 --- a/tests/Support/UrlGenerator/BaseUrlGeneratorTest.php +++ b/tests/Support/UrlGenerator/BaseUrlGeneratorTest.php @@ -40,13 +40,13 @@ }); it('appends a version string when versioning is enabled', function () { - config()->set('medialibrary.version_urls', true); + config()->set('media-library.version_urls', true); $url = '/media/'.$this->media->id.'/conversions/test-'.$this->conversion->getName().'.jpg?v='.$this->media->updated_at->timestamp; expect($this->urlGenerator->getUrl())->toEqual($url); - config()->set('medialibrary.version_urls', false); + config()->set('media-library.version_urls', false); $url = '/media/'.$this->media->id.'/conversions/test-'.$this->conversion->getName().'.jpg';