1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jorijn\LaravelSecurityChecker; |
4
|
|
|
|
5
|
|
|
use Jorijn\LaravelSecurityChecker\Console\SecurityCommand; |
6
|
|
|
use Jorijn\LaravelSecurityChecker\Console\SecurityMailCommand; |
7
|
|
|
|
8
|
|
|
class ServiceProvider extends \Illuminate\Support\ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Indicates if loading of the provider is deferred. |
12
|
|
|
* |
13
|
|
|
* @var bool |
14
|
|
|
*/ |
15
|
|
|
protected $defer = false; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Register the service provider. |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
6 |
|
public function register() |
23
|
|
|
{ |
24
|
6 |
|
$configPath = __DIR__.'/../config/laravel-security-checker.php'; |
25
|
6 |
|
$this->mergeConfigFrom($configPath, 'laravel-security-checker'); |
26
|
6 |
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Bootstrap the application events. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
6 |
|
public function boot() |
34
|
|
|
{ |
35
|
|
|
// configuration |
36
|
6 |
|
$configPath = __DIR__.'/../config/laravel-security-checker.php'; |
37
|
6 |
|
$this->publishes([ $configPath => $this->getConfigPath() ], 'config'); |
38
|
|
|
|
39
|
|
|
// views |
40
|
6 |
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-security-checker'); |
41
|
6 |
|
$this->publishes([ |
42
|
6 |
|
__DIR__.'/../resources/views' => resource_path('views/vendor/laravel-security-checker'), |
43
|
6 |
|
], 'views'); |
44
|
|
|
|
45
|
|
|
// translations |
46
|
6 |
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-security-checker'); |
47
|
6 |
|
$this->publishes([ |
48
|
6 |
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-security-checker'), |
49
|
6 |
|
], 'translations'); |
50
|
|
|
|
51
|
6 |
|
if ($this->app->runningInConsole()) { |
52
|
6 |
|
$this->commands([ |
53
|
6 |
|
SecurityCommand::class, |
54
|
2 |
|
SecurityMailCommand::class, |
55
|
2 |
|
]); |
56
|
2 |
|
} |
57
|
6 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get the config path |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
6 |
|
protected function getConfigPath() |
65
|
|
|
{ |
66
|
6 |
|
return config_path('laravel-security-checker.php'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Publish the config file |
71
|
|
|
* |
72
|
|
|
* @param string $configPath |
73
|
|
|
*/ |
74
|
|
|
protected function publishConfig($configPath) |
75
|
|
|
{ |
76
|
|
|
$this->publishes([ $configPath => config_path('laravel-security-checker.php') ], 'config'); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|