1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of ibrand/setting. |
5
|
|
|
* |
6
|
|
|
* (c) iBrand <https://www.ibrand.cc> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace iBrand\Component\Setting; |
13
|
|
|
|
14
|
|
|
use iBrand\Component\Setting\Models\SystemSetting; |
15
|
|
|
use iBrand\Component\Setting\Repositories\CacheDecorator; |
16
|
|
|
use iBrand\Component\Setting\Repositories\EloquentSetting; |
17
|
|
|
use iBrand\Component\Setting\Repositories\SettingInterface; |
18
|
|
|
use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class ServiceProvider |
22
|
|
|
* @package iBrand\Component\Setting |
23
|
|
|
*/ |
24
|
|
|
class ServiceProvider extends LaravelServiceProvider |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var bool |
28
|
|
|
*/ |
29
|
|
|
protected $defer = true; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* boot service provider |
33
|
|
|
*/ |
34
|
|
|
public function boot() |
35
|
|
|
{ |
36
|
|
|
if ($this->app->runningInConsole()) { |
37
|
|
|
$this->registerMigrations(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$this->publishes([ |
41
|
|
|
__DIR__.'/config.php' => config_path('ibrand/setting.php'), |
42
|
|
|
]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* register service provider |
47
|
|
|
*/ |
48
|
|
|
public function register() |
49
|
|
|
{ |
50
|
|
|
// merge configs |
51
|
|
|
$this->mergeConfigFrom( |
52
|
|
|
__DIR__.'/config.php', 'ibrand.setting' |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$this->app->singleton(SettingInterface::class, function ($app) { |
|
|
|
|
56
|
|
|
$repository = new EloquentSetting(new SystemSetting()); |
57
|
|
|
|
58
|
|
|
if (!config('ibrand.setting.cache')) { |
59
|
|
|
return $repository; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return new CacheDecorator($repository); |
63
|
|
|
}); |
64
|
|
|
|
65
|
|
|
$this->app->alias(SettingInterface::class, 'system_setting'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Register Passport's migration files. |
70
|
|
|
*/ |
71
|
|
|
protected function registerMigrations() |
72
|
|
|
{ |
73
|
|
|
return $this->loadMigrationsFrom(__DIR__.'/../migrations'); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.