|
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
|
201 |
|
public function getBasePath() |
|
42
|
|
|
{ |
|
43
|
201 |
|
return dirname(__DIR__); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
47
|
|
|
| Main Functions |
|
48
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
49
|
|
|
*/ |
|
50
|
|
|
/** |
|
51
|
|
|
* Register the service provider. |
|
52
|
|
|
*/ |
|
53
|
201 |
|
public function register() |
|
54
|
|
|
{ |
|
55
|
201 |
|
$this->registerConfig(); |
|
56
|
201 |
|
$this->registerSettingsManager(); |
|
57
|
201 |
|
$this->registerSettingsStore(); |
|
58
|
201 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Boot the service provider. |
|
62
|
|
|
*/ |
|
63
|
201 |
|
public function boot() |
|
64
|
|
|
{ |
|
65
|
201 |
|
parent::boot(); |
|
66
|
|
|
|
|
67
|
201 |
|
$this->publishes([ |
|
68
|
201 |
|
$this->getConfigFile() => config_path('settings.php') |
|
69
|
201 |
|
], 'config'); |
|
70
|
|
|
|
|
71
|
201 |
|
$this->publishes([ |
|
72
|
201 |
|
$this->getBasePath() . '/database/migrations/' => database_path('migrations') |
|
73
|
201 |
|
], 'migrations'); |
|
74
|
201 |
|
} |
|
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
|
201 |
|
private function registerSettingsManager() |
|
98
|
|
|
{ |
|
99
|
|
|
$this->singleton('arcanedev.settings.manager', function(Application $app) { |
|
100
|
15 |
|
return new SettingsManager($app); |
|
101
|
201 |
|
}); |
|
102
|
201 |
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Register the Settings Store. |
|
106
|
|
|
*/ |
|
107
|
|
|
private function registerSettingsStore() |
|
108
|
|
|
{ |
|
109
|
201 |
|
$this->bind('arcanedev.settings.store', function(Application $app) { |
|
110
|
6 |
|
return $app->make('arcanedev.settings.manager')->driver(); |
|
111
|
201 |
|
}); |
|
112
|
|
|
|
|
113
|
201 |
|
$this->bind( |
|
114
|
201 |
|
\Arcanedev\Settings\Contracts\Store::class, |
|
115
|
|
|
'arcanedev.settings.store' |
|
116
|
201 |
|
); |
|
117
|
201 |
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|