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