1 | <?php namespace Arcanedev\Support; |
||
12 | abstract class PackageServiceProvider extends ServiceProvider |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Properties |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | /** |
||
19 | * Vendor name. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $vendor = 'arcanedev'; |
||
24 | |||
25 | /** |
||
26 | * Package name. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $package = ''; |
||
31 | |||
32 | /** |
||
33 | * Package base path. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $basePath = ''; |
||
38 | |||
39 | /** |
||
40 | * Merge multiple config files into one instance (package name as root key) |
||
41 | * |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $multiConfigs = false; |
||
45 | |||
46 | /* ------------------------------------------------------------------------------------------------ |
||
47 | | Getters & Setters |
||
48 | | ------------------------------------------------------------------------------------------------ |
||
49 | */ |
||
50 | /** |
||
51 | * Get the base path of the package. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | abstract public function getBasePath(); |
||
56 | |||
57 | /** |
||
58 | * Get config folder. |
||
59 | * |
||
60 | * @return string |
||
61 | 9 | */ |
|
62 | protected function getConfigFolder() |
||
66 | |||
67 | /** |
||
68 | * Get config key. |
||
69 | * |
||
70 | * @return string |
||
71 | 9 | */ |
|
72 | protected function getConfigKey() |
||
73 | 9 | { |
|
74 | return Str::slug($this->package); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Get config file path. |
||
79 | * |
||
80 | * @return string |
||
81 | 9 | */ |
|
82 | protected function getConfigFile() |
||
83 | 9 | { |
|
84 | return $this->getConfigFolder().DS."{$this->package}.php"; |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Get the migrations path. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | protected function getMigrationsPath() |
||
96 | |||
97 | /** |
||
98 | * Get the views path. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | private function getViewsPath() |
||
106 | |||
107 | 9 | /* ------------------------------------------------------------------------------------------------ |
|
108 | | Main Functions |
||
109 | 9 | | ------------------------------------------------------------------------------------------------ |
|
110 | 9 | */ |
|
111 | 9 | /** |
|
112 | * Boot the service provider. |
||
113 | */ |
||
114 | public function boot() |
||
120 | 9 | ||
121 | 9 | /* ------------------------------------------------------------------------------------------------ |
|
122 | | Package Functions |
||
123 | 9 | | ------------------------------------------------------------------------------------------------ |
|
124 | 9 | */ |
|
125 | /** |
||
126 | * Setup package path and stuff. |
||
127 | */ |
||
128 | protected function setup() |
||
133 | |||
134 | /** |
||
135 | * Register configs. |
||
136 | * |
||
137 | * @param string $separator |
||
138 | */ |
||
139 | protected function registerConfig($separator = '.') |
||
146 | |||
147 | /** |
||
148 | * Register all package configs. |
||
149 | * |
||
150 | * @param string $separator |
||
151 | */ |
||
152 | private function registerMultipleConfigs($separator = '.') |
||
161 | |||
162 | /** |
||
163 | * Register commands service provider. |
||
164 | * |
||
165 | * @param \Illuminate\Support\ServiceProvider|string $provider |
||
166 | */ |
||
167 | protected function registerCommands($provider) |
||
172 | |||
173 | /** |
||
174 | * Publish the config file. |
||
175 | */ |
||
176 | protected function publishConfig() |
||
182 | |||
183 | /** |
||
184 | * Publish the migration files. |
||
185 | */ |
||
186 | protected function publishMigrations() |
||
194 | |||
195 | /** |
||
196 | * Publish and load the views if $load argument is true. |
||
197 | * |
||
198 | * @param bool $load |
||
199 | */ |
||
200 | protected function publishViews($load = true) |
||
210 | |||
211 | /** |
||
212 | * Publish and load the translations if $load argument is true. |
||
213 | * |
||
214 | * @param bool $load |
||
215 | */ |
||
216 | protected function publishTranslations($load = true) |
||
226 | |||
227 | /** |
||
228 | * Publish the factories. |
||
229 | */ |
||
230 | protected function publishFactories() |
||
238 | |||
239 | /** |
||
240 | * Publish all the package files. |
||
241 | * |
||
242 | * @param bool $load |
||
243 | */ |
||
244 | protected function publishAll($load = true) |
||
252 | |||
253 | /** |
||
254 | * Load the views files. |
||
255 | */ |
||
256 | protected function loadViews() |
||
260 | 3 | ||
261 | /** |
||
262 | 9 | * Load the translations files. |
|
263 | */ |
||
264 | protected function loadTranslations() |
||
268 | |||
269 | /** |
||
270 | * Load the migrations files. |
||
271 | */ |
||
272 | protected function loadMigrations() |
||
276 | |||
277 | /* ------------------------------------------------------------------------------------------------ |
||
278 | | Check Functions |
||
279 | | ------------------------------------------------------------------------------------------------ |
||
280 | */ |
||
281 | /** |
||
282 | * Check package name. |
||
283 | * |
||
284 | * @throws PackageException |
||
285 | */ |
||
286 | private function checkPackageName() |
||
292 | |||
293 | /** |
||
294 | * Check if has the base config. |
||
295 | * |
||
296 | * @return bool |
||
297 | */ |
||
298 | protected function hasPackageConfig() |
||
302 | } |
||
303 |