|
1
|
|
|
<?php namespace Arcanedev\Sanitizer; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Support\PackageServiceProvider as ServiceProvider; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class SanitizerServiceProvider |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanedev\Sanitizer |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class SanitizerServiceProvider extends ServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
14
|
|
|
| Properties |
|
15
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
16
|
|
|
*/ |
|
17
|
|
|
/** |
|
18
|
|
|
* Package name. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $package = 'sanitizer'; |
|
23
|
|
|
|
|
24
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
25
|
|
|
| Getters & Setters |
|
26
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
27
|
|
|
*/ |
|
28
|
|
|
/** |
|
29
|
|
|
* Get the base path of the package. |
|
30
|
|
|
* |
|
31
|
|
|
* @return string |
|
32
|
|
|
*/ |
|
33
|
99 |
|
public function getBasePath() |
|
34
|
|
|
{ |
|
35
|
99 |
|
return dirname(__DIR__); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
39
|
|
|
| Main Functions |
|
40
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
41
|
|
|
*/ |
|
42
|
|
|
/** |
|
43
|
|
|
* Register the service provider. |
|
44
|
|
|
*/ |
|
45
|
99 |
|
public function register() |
|
46
|
|
|
{ |
|
47
|
99 |
|
$this->registerConfig(); |
|
48
|
99 |
|
$this->registerSanitizer(); |
|
49
|
99 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Bootstrap the application events. |
|
53
|
|
|
*/ |
|
54
|
99 |
|
public function boot() |
|
55
|
|
|
{ |
|
56
|
99 |
|
parent::boot(); |
|
57
|
|
|
|
|
58
|
99 |
|
$this->publishConfig(); |
|
59
|
99 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get the services provided by the provider. |
|
63
|
|
|
* |
|
64
|
|
|
* @return array |
|
65
|
|
|
*/ |
|
66
|
9 |
|
public function provides() |
|
67
|
|
|
{ |
|
68
|
|
|
return [ |
|
69
|
9 |
|
Contracts\Sanitizer::class, |
|
70
|
3 |
|
'arcanedev.sanitizer', |
|
71
|
3 |
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
75
|
|
|
| Other functions |
|
76
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
77
|
|
|
*/ |
|
78
|
|
|
/** |
|
79
|
|
|
* Register Helpers. |
|
80
|
|
|
*/ |
|
81
|
|
|
private function registerSanitizer() |
|
82
|
|
|
{ |
|
83
|
99 |
|
$this->singleton(Contracts\Sanitizer::class, function ($app) { |
|
84
|
|
|
/** @var \Illuminate\Contracts\Config\Repository $config */ |
|
85
|
90 |
|
$config = $app['config']; |
|
86
|
|
|
|
|
87
|
90 |
|
return new Factory($config->get('sanitizer.filters')); |
|
88
|
99 |
|
}); |
|
89
|
|
|
|
|
90
|
99 |
|
$this->singleton('arcanedev.sanitizer', Contracts\Sanitizer::class); |
|
91
|
99 |
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|