1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* src/EncryptionServiceProvider.php. |
4
|
|
|
* |
5
|
|
|
* @author Austin Heap <[email protected]> |
6
|
|
|
* @version v0.2.1 |
7
|
|
|
*/ |
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace AustinHeap\Database\Encryption; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* EncryptionServiceProvider. |
14
|
|
|
* |
15
|
|
|
* @link https://github.com/austinheap/laravel-database-encryption |
16
|
|
|
* @link https://packagist.org/packages/austinheap/laravel-database-encryption |
17
|
|
|
* @link https://austinheap.github.io/laravel-database-encryption/classes/AustinHeap.Database.Encryption.EncryptionServiceProvider.html |
18
|
|
|
*/ |
19
|
|
|
class EncryptionServiceProvider extends \Illuminate\Support\ServiceProvider |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Indicates if loading of the provider is deferred. |
23
|
|
|
* |
24
|
|
|
* @var bool |
25
|
|
|
*/ |
26
|
|
|
protected $defer = false; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Bootstrap the application services. |
30
|
|
|
* |
31
|
|
|
* This method is called after all other service providers have |
32
|
|
|
* been registered, meaning you have access to all other services |
33
|
|
|
* that have been registered by the framework. |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
86 |
|
public function boot(): void |
38
|
|
|
{ |
39
|
86 |
|
$this->publishes([__DIR__.'/../config/database-encryption.php' => config_path('database-encryption.php')]); |
40
|
|
|
|
41
|
86 |
|
if (! defined('LARAVEL_DATABASE_ENCRYPTION_VERSION')) { |
42
|
1 |
|
define('LARAVEL_DATABASE_ENCRYPTION_VERSION', EncryptionHelper::VERSION); |
43
|
|
|
} |
44
|
|
|
|
45
|
86 |
|
foreach (EncryptionDefaults::getHelpersDefault() as $helper) { |
46
|
86 |
|
throw_if(! empty($helper) && ! function_exists($helper), |
47
|
86 |
|
'The provider did not boot helper function: "'.$helper.'".'); |
48
|
|
|
} |
49
|
86 |
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Register the application services. |
53
|
|
|
* |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
86 |
|
public function register(): void |
57
|
|
|
{ |
58
|
86 |
|
$this->mergeConfigFrom(__DIR__.'/../config/database-encryption.php', 'database-encryption'); |
59
|
|
|
|
60
|
|
|
$this->app->singleton(EncryptionFacade::getFacadeAccessor(), function ($app) { |
|
|
|
|
61
|
29 |
|
return new EncryptionHelper(); |
62
|
86 |
|
}); |
63
|
|
|
|
64
|
86 |
|
$this->commands([\AustinHeap\Database\Encryption\Console\Commands\MigrateEncryptionCommand::class]); |
65
|
86 |
|
} |
66
|
|
|
} |
67
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.