1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\MediaLibrary; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Spatie\MediaLibrary\Commands\CleanCommand; |
7
|
|
|
use Spatie\MediaLibrary\Commands\ClearCommand; |
8
|
|
|
use Spatie\MediaLibrary\Filesystem\Filesystem; |
9
|
|
|
use Spatie\MediaLibrary\Commands\RegenerateCommand; |
10
|
|
|
use Spatie\MediaLibrary\Filesystem\DefaultFilesystem; |
11
|
|
|
|
12
|
|
|
class MediaLibraryServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Bootstrap the application events. |
16
|
|
|
*/ |
17
|
|
|
public function boot() |
18
|
|
|
{ |
19
|
|
|
$this->publishes([ |
20
|
|
|
__DIR__.'/../config/medialibrary.php' => config_path('medialibrary.php'), |
21
|
|
|
], 'config'); |
22
|
|
|
|
23
|
|
|
$this->publishes([ |
24
|
|
|
__DIR__.'/../database/migrations/create_media_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_media_table.php'), |
25
|
|
|
], 'migrations'); |
26
|
|
|
|
27
|
|
|
$mediaClass = config('medialibrary.media_model'); |
28
|
|
|
|
29
|
|
|
$mediaClass::observe(new MediaObserver()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Register the service provider. |
34
|
|
|
*/ |
35
|
|
|
public function register() |
36
|
|
|
{ |
37
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/medialibrary.php', 'medialibrary'); |
38
|
|
|
|
39
|
|
|
$this->app->singleton(MediaRepository::class); |
40
|
|
|
|
41
|
|
|
$this->app->bind('command.medialibrary:regenerate', RegenerateCommand::class); |
42
|
|
|
$this->app->bind('command.medialibrary:clear', ClearCommand::class); |
43
|
|
|
$this->app->bind('command.medialibrary:clean', CleanCommand::class); |
44
|
|
|
|
45
|
|
|
$this->app->bind(Filesystem::class, DefaultFilesystem::class); |
46
|
|
|
|
47
|
|
|
$this->commands([ |
48
|
|
|
'command.medialibrary:regenerate', |
49
|
|
|
'command.medialibrary:clear', |
50
|
|
|
'command.medialibrary:clean', |
51
|
|
|
]); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|