|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bantenprov\Zona; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
use Bantenprov\Zona\Console\Commands\ZonaCommand; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* The ZonaServiceProvider class |
|
10
|
|
|
* |
|
11
|
|
|
* @package Bantenprov\Zona |
|
12
|
|
|
* @author bantenprov <[email protected]> |
|
13
|
|
|
*/ |
|
14
|
|
|
class ZonaServiceProvider extends ServiceProvider |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Indicates if loading of the provider is deferred. |
|
18
|
|
|
* |
|
19
|
|
|
* @var bool |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $defer = false; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Bootstrap the application events. |
|
25
|
|
|
* |
|
26
|
|
|
* @return void |
|
27
|
|
|
*/ |
|
28
|
|
|
public function boot() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->routeHandle(); |
|
31
|
|
|
$this->configHandle(); |
|
32
|
|
|
$this->langHandle(); |
|
33
|
|
|
$this->viewHandle(); |
|
34
|
|
|
$this->assetHandle(); |
|
35
|
|
|
$this->migrationHandle(); |
|
36
|
|
|
$this->publicHandle(); |
|
37
|
|
|
$this->seedHandle(); |
|
38
|
|
|
$this->publishHandle(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Register the service provider. |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function register() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->app->singleton('zona', function ($app) { |
|
|
|
|
|
|
49
|
|
|
return new Zona; |
|
50
|
|
|
}); |
|
51
|
|
|
|
|
52
|
|
|
$this->app->singleton('command.zona', function ($app) { |
|
|
|
|
|
|
53
|
|
|
return new ZonaCommand; |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
$this->commands('command.zona'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get the services provided by the provider. |
|
61
|
|
|
* |
|
62
|
|
|
* @return array |
|
63
|
|
|
*/ |
|
64
|
|
|
public function provides() |
|
65
|
|
|
{ |
|
66
|
|
|
return [ |
|
67
|
|
|
'zona', |
|
68
|
|
|
'command.zona', |
|
69
|
|
|
]; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Loading and publishing package's config |
|
74
|
|
|
* |
|
75
|
|
|
* @return void |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function configHandle($publish = '') |
|
78
|
|
|
{ |
|
79
|
|
|
$packageConfigPath = __DIR__.'/config'; |
|
80
|
|
|
$appConfigPath = config_path('bantenprov/zona'); |
|
81
|
|
|
|
|
82
|
|
|
$this->mergeConfigFrom($packageConfigPath.'/zona.php', 'zona'); |
|
83
|
|
|
$this->mergeConfigFrom($packageConfigPath.'/master-zona.php', 'master-zona'); |
|
84
|
|
|
|
|
85
|
|
|
$this->publishes([ |
|
86
|
|
|
$packageConfigPath.'/zona.php' => $appConfigPath.'/zona.php', |
|
87
|
|
|
$packageConfigPath.'/master-zona.php' => $appConfigPath.'/master-zona.php', |
|
88
|
|
|
], $publish ? $publish : 'zona-config'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Loading package routes |
|
93
|
|
|
* |
|
94
|
|
|
* @return void |
|
95
|
|
|
*/ |
|
96
|
|
|
protected function routeHandle() |
|
97
|
|
|
{ |
|
98
|
|
|
$this->loadRoutesFrom(__DIR__.'/routes/routes.php'); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Loading and publishing package's translations |
|
103
|
|
|
* |
|
104
|
|
|
* @return void |
|
105
|
|
|
*/ |
|
106
|
|
|
protected function langHandle($publish = '') |
|
107
|
|
|
{ |
|
108
|
|
|
$packageTranslationsPath = __DIR__.'/resources/lang'; |
|
109
|
|
|
|
|
110
|
|
|
$this->loadTranslationsFrom($packageTranslationsPath, 'zona'); |
|
111
|
|
|
|
|
112
|
|
|
$this->publishes([ |
|
113
|
|
|
$packageTranslationsPath => resource_path('lang/vendor/zona'), |
|
114
|
|
|
], $publish ? $publish : 'zona-lang'); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Loading and publishing package's views |
|
119
|
|
|
* |
|
120
|
|
|
* @return void |
|
121
|
|
|
*/ |
|
122
|
|
|
protected function viewHandle($publish = '') |
|
123
|
|
|
{ |
|
124
|
|
|
$packageViewsPath = __DIR__.'/resources/views'; |
|
125
|
|
|
|
|
126
|
|
|
$this->loadViewsFrom($packageViewsPath, 'zona'); |
|
127
|
|
|
|
|
128
|
|
|
$this->publishes([ |
|
129
|
|
|
$packageViewsPath => resource_path('views/vendor/zona'), |
|
130
|
|
|
], $publish ? $publish : 'zona-views'); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Publishing package's assets (JavaScript, CSS, images...) |
|
135
|
|
|
* |
|
136
|
|
|
* @return void |
|
137
|
|
|
*/ |
|
138
|
|
|
protected function assetHandle($publish = '') |
|
139
|
|
|
{ |
|
140
|
|
|
$packageAssetsPath = __DIR__.'/resources/assets'; |
|
141
|
|
|
|
|
142
|
|
|
$this->publishes([ |
|
143
|
|
|
$packageAssetsPath => resource_path('assets'), |
|
144
|
|
|
], $publish ? $publish : 'zona-assets'); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Publishing package's migrations |
|
149
|
|
|
* |
|
150
|
|
|
* @return void |
|
151
|
|
|
*/ |
|
152
|
|
|
protected function migrationHandle($publish = '') |
|
153
|
|
|
{ |
|
154
|
|
|
$packageMigrationsPath = __DIR__.'/database/migrations'; |
|
155
|
|
|
|
|
156
|
|
|
$this->loadMigrationsFrom($packageMigrationsPath); |
|
157
|
|
|
|
|
158
|
|
|
$this->publishes([ |
|
159
|
|
|
$packageMigrationsPath => database_path('migrations') |
|
160
|
|
|
], $publish ? $publish : 'zona-migrations'); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Publishing package's publics (JavaScript, CSS, images...) |
|
165
|
|
|
* |
|
166
|
|
|
* @return void |
|
167
|
|
|
*/ |
|
168
|
|
|
public function publicHandle($publish = '') |
|
169
|
|
|
{ |
|
170
|
|
|
$packagePublicPath = __DIR__.'/public'; |
|
171
|
|
|
|
|
172
|
|
|
$this->publishes([ |
|
173
|
|
|
$packagePublicPath => base_path('public') |
|
174
|
|
|
], $publish ? $publish : 'zona-public'); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Publishing package's seeds |
|
179
|
|
|
* |
|
180
|
|
|
* @return void |
|
181
|
|
|
*/ |
|
182
|
|
|
public function seedHandle($publish = '') |
|
183
|
|
|
{ |
|
184
|
|
|
$packageSeedPath = __DIR__.'/database/seeds'; |
|
185
|
|
|
|
|
186
|
|
|
$this->publishes([ |
|
187
|
|
|
$packageSeedPath => base_path('database/seeds') |
|
188
|
|
|
], $publish ? $publish : 'zona-seeds'); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Publishing package's all files |
|
193
|
|
|
* |
|
194
|
|
|
* @return void |
|
195
|
|
|
*/ |
|
196
|
|
|
public function publishHandle() |
|
197
|
|
|
{ |
|
198
|
|
|
$publish = 'zona-publish'; |
|
199
|
|
|
|
|
200
|
|
|
$this->routeHandle($publish); |
|
|
|
|
|
|
201
|
|
|
$this->configHandle($publish); |
|
202
|
|
|
$this->langHandle($publish); |
|
203
|
|
|
$this->viewHandle($publish); |
|
204
|
|
|
$this->assetHandle($publish); |
|
205
|
|
|
// $this->migrationHandle($publish); |
|
|
|
|
|
|
206
|
|
|
$this->publicHandle($publish); |
|
207
|
|
|
$this->seedHandle($publish); |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.