1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NStack; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Str; |
6
|
|
|
use Illuminate\Translation\TranslationServiceProvider; |
7
|
|
|
use NStack\Translation\NStackLoader; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class ServiceProvider. |
11
|
|
|
*/ |
12
|
|
|
class ServiceProvider extends TranslationServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* boot |
16
|
|
|
* |
17
|
|
|
* @author Casper Rasmussen <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
public function boot() |
20
|
|
|
{ |
21
|
|
|
if (!Str::contains($this->app->version(), 'Lumen')) { |
22
|
|
|
$this->publishGroups(); |
23
|
|
|
} |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* register |
28
|
|
|
* |
29
|
|
|
* @author Casper Rasmussen <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
public function register() |
32
|
|
|
{ |
33
|
|
|
$this->registerManager(); |
34
|
|
|
$this->setupBindings(); |
35
|
|
|
parent::register(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* publishGroups |
40
|
|
|
* |
41
|
|
|
* @author Casper Rasmussen <[email protected]> |
42
|
|
|
*/ |
43
|
|
|
protected function publishGroups() |
44
|
|
|
{ |
45
|
|
|
$this->publishes([ |
46
|
|
|
__DIR__.'/../config' => config_path(), |
47
|
|
|
], 'config'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Setup container binding. |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
* @author Casper Rasmussen <[email protected]> |
55
|
|
|
*/ |
56
|
|
|
protected function setupBindings() |
57
|
|
|
{ |
58
|
|
|
$this->app->bind(NStack::class, function ($app) { |
59
|
|
|
return $app['nstack']; |
60
|
|
|
}); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritDoc} |
65
|
|
|
* @see \Illuminate\Translation\TranslationServiceProvider::registerLoader() |
66
|
|
|
*/ |
67
|
|
|
protected function registerLoader() |
68
|
|
|
{ |
69
|
|
|
$this->app->singleton('translation.loader', function ($app) { |
70
|
|
|
return new NStackLoader($app['files'], $app['path.lang'], $app->get('nstack')); |
71
|
|
|
}); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Register assets manager. |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
* @author Casper Rasmussen <[email protected]> |
79
|
|
|
*/ |
80
|
|
|
public function registerManager() |
81
|
|
|
{ |
82
|
|
|
$this->app->singleton('nstack', function () { |
83
|
|
|
$configArray = config('nstack'); |
84
|
|
|
|
85
|
|
|
$config = Config::createFromArray($configArray); |
86
|
|
|
|
87
|
|
|
return new NStack($config); |
88
|
|
|
}); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|