|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Arcanedev\NoCaptcha; |
|
6
|
|
|
|
|
7
|
|
|
use Arcanedev\NoCaptcha\Contracts\NoCaptcha as NoCaptchaContract; |
|
8
|
|
|
use Arcanedev\NoCaptcha\Contracts\NoCaptchaManager as NoCaptchaManagerContract; |
|
9
|
|
|
use Arcanedev\Support\Providers\PackageServiceProvider as ServiceProvider; |
|
10
|
|
|
use Illuminate\Contracts\Foundation\Application; |
|
11
|
|
|
use Illuminate\Contracts\Support\DeferrableProvider; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class NoCaptchaServiceProvider |
|
15
|
|
|
* |
|
16
|
|
|
* @author ARCANEDEV <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class NoCaptchaServiceProvider extends ServiceProvider implements DeferrableProvider |
|
19
|
|
|
{ |
|
20
|
|
|
/* ----------------------------------------------------------------- |
|
21
|
|
|
| Properties |
|
22
|
|
|
| ----------------------------------------------------------------- |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Package name. |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $package = 'no-captcha'; |
|
31
|
|
|
|
|
32
|
|
|
/* ----------------------------------------------------------------- |
|
33
|
|
|
| Main Methods |
|
34
|
|
|
| ----------------------------------------------------------------- |
|
35
|
|
|
*/ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Register the service provider. |
|
39
|
|
|
*/ |
|
40
|
44 |
|
public function register(): void |
|
41
|
|
|
{ |
|
42
|
44 |
|
parent::register(); |
|
43
|
|
|
|
|
44
|
44 |
|
$this->registerConfig(); |
|
45
|
44 |
|
$this->registerNoCaptchaManager(); |
|
46
|
44 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Bootstrap the application events. |
|
50
|
|
|
*/ |
|
51
|
44 |
|
public function boot(): void |
|
52
|
|
|
{ |
|
53
|
44 |
|
if ($this->app->runningInConsole()) { |
|
54
|
44 |
|
$this->publishConfig(); |
|
55
|
|
|
} |
|
56
|
44 |
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Get the services provided by the provider. |
|
60
|
|
|
* |
|
61
|
|
|
* @return array |
|
62
|
|
|
*/ |
|
63
|
4 |
|
public function provides(): array |
|
64
|
|
|
{ |
|
65
|
|
|
return [ |
|
66
|
4 |
|
NoCaptchaContract::class, |
|
67
|
|
|
NoCaptchaManagerContract::class, |
|
68
|
|
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/* ----------------------------------------------------------------- |
|
72
|
|
|
| Other Methods |
|
73
|
|
|
| ----------------------------------------------------------------- |
|
74
|
|
|
*/ |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Register noCaptcha manager & contract. |
|
78
|
|
|
*/ |
|
79
|
44 |
|
private function registerNoCaptchaManager(): void |
|
80
|
|
|
{ |
|
81
|
22 |
|
$this->singleton(NoCaptchaManagerContract::class, NoCaptchaManager::class); |
|
82
|
|
|
|
|
83
|
22 |
|
$this->bind(NoCaptchaContract::class, function (Application $app) { |
|
84
|
|
|
/** @var \Illuminate\Contracts\Config\Repository $config */ |
|
85
|
20 |
|
$config = $app['config']; |
|
86
|
|
|
|
|
87
|
10 |
|
return $app->make(NoCaptchaManagerContract::class)->version( |
|
88
|
20 |
|
$config->get('no-captcha.version') |
|
89
|
|
|
); |
|
90
|
44 |
|
}); |
|
91
|
44 |
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|