1
|
|
|
<?php namespace Arcanedev\Settings; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Support\PackageServiceProvider as ServiceProvider; |
4
|
|
|
use Illuminate\Foundation\Application; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class SettingsServiceProvider |
8
|
|
|
* |
9
|
|
|
* @package Arcanedev\Settings |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class SettingsServiceProvider 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 = 'settings'; |
31
|
|
|
|
32
|
|
|
/* ------------------------------------------------------------------------------------------------ |
33
|
|
|
| Getters & Setters |
34
|
|
|
| ------------------------------------------------------------------------------------------------ |
35
|
|
|
*/ |
36
|
|
|
/** |
37
|
|
|
* Get the base path of the package. |
38
|
|
|
* |
39
|
|
|
* @return string |
40
|
|
|
*/ |
41
|
195 |
|
public function getBasePath() |
42
|
|
|
{ |
43
|
195 |
|
return dirname(__DIR__); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/* ------------------------------------------------------------------------------------------------ |
47
|
|
|
| Main Functions |
48
|
|
|
| ------------------------------------------------------------------------------------------------ |
49
|
|
|
*/ |
50
|
|
|
/** |
51
|
|
|
* Register the service provider. |
52
|
|
|
*/ |
53
|
195 |
|
public function register() |
54
|
|
|
{ |
55
|
195 |
|
$this->registerConfig(); |
56
|
195 |
|
$this->registerSettingsManager(); |
57
|
195 |
|
$this->registerSettingsStore(); |
58
|
195 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Boot the service provider. |
62
|
|
|
*/ |
63
|
195 |
|
public function boot() |
64
|
|
|
{ |
65
|
195 |
|
parent::boot(); |
66
|
|
|
|
67
|
195 |
|
$this->publishes([ |
68
|
195 |
|
$this->getConfigFile() => config_path('settings.php') |
69
|
195 |
|
], 'config'); |
70
|
|
|
|
71
|
195 |
|
$this->publishes([ |
72
|
195 |
|
$this->getBasePath() . '/database/migrations/' => database_path('migrations') |
73
|
195 |
|
], 'migrations'); |
74
|
195 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the services provided by the provider. |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
3 |
|
public function provides() |
82
|
|
|
{ |
83
|
|
|
return [ |
84
|
3 |
|
'arcanedev.settings.manager', |
85
|
3 |
|
'arcanedev.settings.store', |
86
|
3 |
|
\Arcanedev\Settings\Contracts\Store::class, |
87
|
3 |
|
]; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/* ------------------------------------------------------------------------------------------------ |
91
|
|
|
| Other Functions |
92
|
|
|
| ------------------------------------------------------------------------------------------------ |
93
|
|
|
*/ |
94
|
|
|
/** |
95
|
|
|
* Register the Settings Manager. |
96
|
|
|
*/ |
97
|
195 |
|
private function registerSettingsManager() |
98
|
|
|
{ |
99
|
|
|
$this->singleton('arcanedev.settings.manager', function(Application $app) { |
100
|
15 |
|
return new SettingsManager($app); |
101
|
195 |
|
}); |
102
|
195 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Register the Settings Store. |
106
|
|
|
*/ |
107
|
|
|
private function registerSettingsStore() |
108
|
|
|
{ |
109
|
195 |
|
$this->bind('arcanedev.settings.store', function(Application $app) { |
110
|
6 |
|
return $app->make('arcanedev.settings.manager')->driver(); |
111
|
195 |
|
}); |
112
|
|
|
|
113
|
195 |
|
$this->bind( |
114
|
195 |
|
\Arcanedev\Settings\Contracts\Store::class, |
115
|
|
|
'arcanedev.settings.store' |
116
|
195 |
|
); |
117
|
195 |
|
} |
118
|
|
|
} |
119
|
|
|
|