1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ElfSundae\Laravel\Support; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Illuminate\Support\Str; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
|
9
|
|
|
class SupportServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Bootstrap the application services. |
13
|
|
|
* |
14
|
|
|
* @return void |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'support'); |
19
|
|
|
|
20
|
|
|
if ($this->app->runningInConsole()) { |
21
|
|
|
$this->publishes([ |
22
|
|
|
__DIR__.'/../config/support.php' => config_path('support.php'), |
23
|
|
|
], 'laravel-support-config'); |
24
|
|
|
|
25
|
|
|
$this->publishes([ |
26
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang'), |
27
|
|
|
], 'laravel-support-lang'); |
28
|
|
|
|
29
|
|
|
$this->publishes([ |
30
|
|
|
__DIR__.'/../resources/views' => resource_path('views/vendor/support'), |
31
|
|
|
], 'laravel-support-views'); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Register the application service. |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function register() |
41
|
|
|
{ |
42
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/support.php', 'support'); |
43
|
|
|
|
44
|
|
|
$this->setupConfiguration(); |
45
|
|
|
|
46
|
|
|
if ($this->app->runningInConsole()) { |
47
|
|
|
$this->commands([ |
48
|
|
|
Console\IdeHelperGenerateCommand::class, |
49
|
|
|
]); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Setup application configurations. |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
protected function setupConfiguration() |
59
|
|
|
{ |
60
|
|
|
if (! $this->app->configurationIsCached()) { |
61
|
|
|
if ($defaults = $this->app['config']['support.config.default']) { |
62
|
|
|
$this->app['config']->set($defaults); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$this->configureForCurrentRequest(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Configure application for the current request. |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
protected function configureForCurrentRequest() |
75
|
|
|
{ |
76
|
|
|
if (app_id() && $appConfig = $this->app['config']->get('support.config.'.app_id())) { |
77
|
|
|
$this->app['config']->set($appConfig); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if ($carbonLocale = $this->app['config']['support.carbon_locale']) { |
81
|
|
|
Carbon::setLocale($carbonLocale); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|