From 14ca7d312f7ed304864af5e336eb5ddf4118a43b Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 3 Jan 2024 12:19:15 +0100 Subject: [PATCH] Add config path --- config/media-library.php | 5 +++++ src/ServiceProvider.php | 6 +++++- tests/Feature/InstallTest.php | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 config/media-library.php create mode 100644 tests/Feature/InstallTest.php diff --git a/config/media-library.php b/config/media-library.php new file mode 100644 index 0000000..b700c8d --- /dev/null +++ b/config/media-library.php @@ -0,0 +1,5 @@ + 'temp', +]; diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 00da40e..e4d7597 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -2,7 +2,9 @@ namespace Zoomyboy\MedialibraryHelper; +use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Routing\Router; +use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider as BaseServiceProvider; use Spatie\MediaLibrary\MediaCollections\MediaCollection; @@ -12,6 +14,8 @@ class ServiceProvider extends BaseServiceProvider { app()->bind('media-library-helpers', fn () => collect([])); app()->singleton(CollectionExtension::class, fn () => new CollectionExtension()); + + $this->mergeConfigFrom(__DIR__ . '/../config/media-library.php', 'media-library'); } public function boot(): void @@ -24,8 +28,8 @@ class ServiceProvider extends BaseServiceProvider $router->patch('mediaupload/{media}', [MediaController::class, 'update'])->name('media.update'); }); + MediaCollection::mixin(app(CollectionExtension::class)); - // app(CollectionExtension::class)->boot(); } /** diff --git a/tests/Feature/InstallTest.php b/tests/Feature/InstallTest.php new file mode 100644 index 0000000..7679e04 --- /dev/null +++ b/tests/Feature/InstallTest.php @@ -0,0 +1,24 @@ + MediaLibraryServiceProvider::class, '--tag' => 'config']); + $configContents = file_get_contents(config_path('media-library.php')); + $configContents = preg_replace('/\'image_driver\' => env.*/', '\'image_driver\' => "lala",', $configContents); + file_put_contents(config_path('media-library.php'), $configContents); + + $this->tearDownTheTestEnvironment(); + $this->setUpTheTestEnvironment(); + + $this->assertEquals('lala', config('media-library.image_driver')); + $this->assertEquals('temp', config('media-library.temp_storage')); +});