1
|
|
|
<?php namespace Arcanesoft\Settings; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Support\PackageServiceProvider; |
4
|
|
|
use Illuminate\Support\Str; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class SettingsServiceProvider |
8
|
|
|
* |
9
|
|
|
* @package Arcanesoft\Settings |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class SettingsServiceProvider extends PackageServiceProvider |
13
|
|
|
{ |
14
|
|
|
/* ------------------------------------------------------------------------------------------------ |
15
|
|
|
| Properties |
16
|
|
|
| ------------------------------------------------------------------------------------------------ |
17
|
|
|
*/ |
18
|
|
|
/** |
19
|
|
|
* Vendor name. |
20
|
|
|
* |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $vendor = 'arcanesoft'; |
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
|
45 |
|
public function getBasePath() |
42
|
|
|
{ |
43
|
45 |
|
return dirname(__DIR__); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get config key. |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
45 |
|
protected function getConfigKey() |
52
|
|
|
{ |
53
|
45 |
|
return Str::slug($this->vendor.' '.$this->package, '.'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/* ------------------------------------------------------------------------------------------------ |
57
|
|
|
| Main Functions |
58
|
|
|
| ------------------------------------------------------------------------------------------------ |
59
|
|
|
*/ |
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
45 |
|
public function register() |
64
|
|
|
{ |
65
|
45 |
|
$this->registerConfig(); |
66
|
45 |
|
$this->registerSettingsManager(); |
67
|
|
|
|
68
|
45 |
|
if ($this->app->runningInConsole()) { |
69
|
45 |
|
$this->app->register(Providers\CommandServiceProvider::class); |
70
|
30 |
|
} |
71
|
45 |
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritdoc} |
75
|
|
|
*/ |
76
|
45 |
|
public function boot() |
77
|
|
|
{ |
78
|
45 |
|
parent::boot(); |
79
|
|
|
|
80
|
|
|
// Config |
81
|
45 |
|
$this->publishes([ |
82
|
45 |
|
$this->getConfigFile() => config_path("{$this->vendor}/{$this->package}.php"), |
83
|
45 |
|
], 'config'); |
84
|
|
|
|
85
|
45 |
|
$this->publishMigrations(); |
86
|
45 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
3 |
|
public function provides() |
92
|
|
|
{ |
93
|
|
|
return [ |
94
|
3 |
|
Contracts\Settings::class, |
95
|
2 |
|
]; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/* ------------------------------------------------------------------------------------------------ |
99
|
|
|
| Services |
100
|
|
|
| ------------------------------------------------------------------------------------------------ |
101
|
|
|
*/ |
102
|
|
|
/** |
103
|
|
|
* Register Settings Manager. |
104
|
|
|
*/ |
105
|
45 |
|
private function registerSettingsManager() |
106
|
|
|
{ |
107
|
45 |
|
$this->singleton(Contracts\Settings::class, SettingsManager::class); |
108
|
45 |
|
} |
109
|
|
|
} |
110
|
|
|
|