1
|
|
|
<?php namespace Arcanedev\LaravelSettings; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Support\PackageServiceProvider; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class SettingsServiceProvider |
7
|
|
|
* |
8
|
|
|
* @package Arcanedev\LaravelSettings |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class SettingsServiceProvider extends PackageServiceProvider |
12
|
|
|
{ |
13
|
|
|
/* ----------------------------------------------------------------- |
14
|
|
|
| Properties |
15
|
|
|
| ----------------------------------------------------------------- |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Package name. |
20
|
|
|
* |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $package = 'settings'; |
24
|
|
|
|
25
|
|
|
/* ----------------------------------------------------------------- |
26
|
|
|
| Getters & Setters |
27
|
|
|
| ----------------------------------------------------------------- |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get the base path of the package. |
32
|
|
|
* |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
258 |
|
public function getBasePath() |
36
|
|
|
{ |
37
|
258 |
|
return dirname(__DIR__); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/* ----------------------------------------------------------------- |
41
|
|
|
| Main Methods |
42
|
|
|
| ----------------------------------------------------------------- |
43
|
|
|
*/ |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Register the service provider. |
47
|
|
|
*/ |
48
|
258 |
|
public function register() |
49
|
|
|
{ |
50
|
258 |
|
parent::register(); |
51
|
|
|
|
52
|
258 |
|
$this->registerConfig(); |
53
|
|
|
|
54
|
258 |
|
$this->registerSettingsManager(); |
55
|
|
|
|
56
|
258 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Boot the service provider. |
60
|
|
|
*/ |
61
|
258 |
|
public function boot() |
62
|
|
|
{ |
63
|
258 |
|
parent::boot(); |
64
|
|
|
|
65
|
258 |
|
$this->publishConfig(); |
66
|
258 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the services provided by the provider. |
70
|
|
|
* |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
6 |
|
public function provides() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
6 |
|
Contracts\Manager::class, |
77
|
2 |
|
Contracts\Store::class, |
78
|
2 |
|
]; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/* ----------------------------------------------------------------- |
82
|
|
|
| Other Methods |
83
|
|
|
| ----------------------------------------------------------------- |
84
|
|
|
*/ |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Register the Settings Manager. |
88
|
|
|
* |
89
|
|
|
*/ |
90
|
258 |
|
private function registerSettingsManager() |
91
|
|
|
{ |
92
|
|
|
$this->singleton(Contracts\Manager::class, function ($app) { |
93
|
246 |
|
return new SettingsManager($app); |
94
|
258 |
|
}); |
95
|
|
|
|
96
|
258 |
|
$this->singleton(Contracts\Store::class, function ($app) { |
97
|
|
|
/** @var \Arcanedev\LaravelSettings\Contracts\Manager $manager */ |
98
|
6 |
|
$manager = $app[Contracts\Manager::class]; |
99
|
|
|
|
100
|
6 |
|
return $manager->driver(); |
101
|
258 |
|
}); |
102
|
258 |
|
} |
103
|
|
|
} |
104
|
|
|
|