Add config path
This commit is contained in:
parent
17afb48028
commit
14ca7d312f
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'temp_storage' => 'temp',
|
||||||
|
];
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace Zoomyboy\MedialibraryHelper;
|
namespace Zoomyboy\MedialibraryHelper;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Events\VendorTagPublished;
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
||||||
use Spatie\MediaLibrary\MediaCollections\MediaCollection;
|
use Spatie\MediaLibrary\MediaCollections\MediaCollection;
|
||||||
|
|
||||||
|
@ -12,6 +14,8 @@ class ServiceProvider extends BaseServiceProvider
|
||||||
{
|
{
|
||||||
app()->bind('media-library-helpers', fn () => collect([]));
|
app()->bind('media-library-helpers', fn () => collect([]));
|
||||||
app()->singleton(CollectionExtension::class, fn () => new CollectionExtension());
|
app()->singleton(CollectionExtension::class, fn () => new CollectionExtension());
|
||||||
|
|
||||||
|
$this->mergeConfigFrom(__DIR__ . '/../config/media-library.php', 'media-library');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
|
@ -24,8 +28,8 @@ class ServiceProvider extends BaseServiceProvider
|
||||||
$router->patch('mediaupload/{media}', [MediaController::class, 'update'])->name('media.update');
|
$router->patch('mediaupload/{media}', [MediaController::class, 'update'])->name('media.update');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
MediaCollection::mixin(app(CollectionExtension::class));
|
MediaCollection::mixin(app(CollectionExtension::class));
|
||||||
// app(CollectionExtension::class)->boot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zoomyboy\MedialibraryHelper\Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Console\VendorPublishCommand;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Spatie\MediaLibrary\MediaLibraryServiceProvider;
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
@unlink(config_path('media-library.php'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('modifies config file', function () {
|
||||||
|
Artisan::call(VendorPublishCommand::class, ['--provider' => 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'));
|
||||||
|
});
|
Loading…
Reference in New Issue