|
1
|
|
|
<?php namespace Arcanesoft\Media; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Core\Bases\PackageServiceProvider; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class MediaServiceProvider |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanesoft\Media |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class MediaServiceProvider extends PackageServiceProvider |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
/* ----------------------------------------------------------------- |
|
14
|
|
|
| Properties |
|
15
|
|
|
| ----------------------------------------------------------------- |
|
16
|
|
|
*/ |
|
17
|
|
|
/** |
|
18
|
|
|
* Package name. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $package = 'media'; |
|
23
|
|
|
|
|
24
|
|
|
/* ----------------------------------------------------------------- |
|
25
|
|
|
| Main Functions |
|
26
|
|
|
| ----------------------------------------------------------------- |
|
27
|
|
|
*/ |
|
28
|
|
|
/** |
|
29
|
|
|
* Register the service provider. |
|
30
|
|
|
*/ |
|
31
|
18 |
|
public function register() |
|
32
|
|
|
{ |
|
33
|
18 |
|
parent::register(); |
|
34
|
|
|
|
|
35
|
18 |
|
$this->registerConfig(); |
|
36
|
18 |
|
$this->registerSidebarItems(); |
|
37
|
18 |
|
$this->registerProviders([ |
|
38
|
18 |
|
Providers\PackagesServiceProvider::class, |
|
39
|
12 |
|
Providers\AuthorizationServiceProvider::class, |
|
40
|
12 |
|
]); |
|
41
|
18 |
|
$this->registerConsoleServiceProvider(Providers\ConsoleServiceProvider::class); |
|
42
|
|
|
|
|
43
|
18 |
|
$this->syncFilesystemConfig(); |
|
44
|
18 |
|
$this->registerMediaManager(); |
|
45
|
18 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Boot the service provider. |
|
49
|
|
|
*/ |
|
50
|
18 |
|
public function boot() |
|
51
|
|
|
{ |
|
52
|
18 |
|
parent::boot(); |
|
53
|
|
|
|
|
54
|
18 |
|
$this->registerProvider(Providers\RouteServiceProvider::class); |
|
55
|
|
|
|
|
56
|
|
|
// Publishes |
|
57
|
18 |
|
$this->publishConfig(); |
|
58
|
18 |
|
$this->publishViews(); |
|
59
|
18 |
|
$this->publishTranslations(); |
|
60
|
18 |
|
$this->publishSidebarItems(); |
|
61
|
18 |
|
$this->publishAssets(); |
|
62
|
18 |
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Get the services provided by the provider. |
|
66
|
|
|
* |
|
67
|
|
|
* @return array |
|
68
|
|
|
*/ |
|
69
|
3 |
|
public function provides() |
|
70
|
|
|
{ |
|
71
|
|
|
return [ |
|
72
|
3 |
|
Contracts\Media::class, |
|
73
|
2 |
|
]; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/* ----------------------------------------------------------------- |
|
77
|
|
|
| Other Methods |
|
78
|
|
|
| ----------------------------------------------------------------- |
|
79
|
|
|
*/ |
|
80
|
|
|
/** |
|
81
|
|
|
* Sync the filesystem config. |
|
82
|
|
|
*/ |
|
83
|
18 |
|
private function syncFilesystemConfig() |
|
84
|
|
|
{ |
|
85
|
18 |
|
foreach ($this->config()->get('arcanesoft.media.filesystem.disks', []) as $disk => $config) { |
|
86
|
18 |
|
$this->config()->set("filesystems.disks.$disk", $config); |
|
87
|
12 |
|
} |
|
88
|
18 |
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Register the media manager. |
|
92
|
|
|
*/ |
|
93
|
18 |
|
private function registerMediaManager() |
|
94
|
|
|
{ |
|
95
|
18 |
|
$this->singleton(Contracts\Media::class, Media::class); |
|
96
|
18 |
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Publish the assets. |
|
100
|
|
|
*/ |
|
101
|
18 |
|
private function publishAssets() |
|
102
|
|
|
{ |
|
103
|
18 |
|
$this->publishes([ |
|
104
|
18 |
|
$this->getResourcesPath().DS.'assets'.DS.'js' => resource_path("assets/back/js/components/{$this->vendor}/{$this->package}"), |
|
|
|
|
|
|
105
|
18 |
|
], 'assets-js'); |
|
106
|
18 |
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|