1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\Backup; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Spatie\Backup\Commands\BackupCommand; |
7
|
|
|
use Spatie\Backup\Commands\CleanupCommand; |
8
|
|
|
use Spatie\Backup\Commands\ListCommand; |
9
|
|
|
use Spatie\Backup\Commands\MonitorCommand; |
10
|
|
|
use Spatie\Backup\Helpers\ConsoleOutput; |
11
|
|
|
|
12
|
|
|
class BackupServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Bootstrap the application services. |
16
|
|
|
*/ |
17
|
|
|
public function boot() |
18
|
|
|
{ |
19
|
|
|
$this->publishes([ |
20
|
|
|
__DIR__ . '/../config/laravel-backup.php' => config_path('laravel-backup.php'), |
21
|
|
|
], 'config'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Register the application services. |
26
|
|
|
*/ |
27
|
|
|
public function register() |
28
|
|
|
{ |
29
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../config/laravel-backup.php', 'laravel-backup'); |
30
|
|
|
|
31
|
|
|
$this->handleDeprecatedConfigValues(); |
32
|
|
|
|
33
|
|
|
$this->app['events']->subscribe(\Spatie\Backup\Notifications\EventHandler::class); |
34
|
|
|
|
35
|
|
|
$this->app->bind('command.backup:run', BackupCommand::class); |
36
|
|
|
$this->app->bind('command.backup:clean', CleanupCommand::class); |
37
|
|
|
$this->app->bind('command.backup:list', ListCommand::class); |
38
|
|
|
$this->app->bind('command.backup:monitor', MonitorCommand::class); |
39
|
|
|
|
40
|
|
|
$this->commands([ |
41
|
|
|
'command.backup:run', |
42
|
|
|
'command.backup:clean', |
43
|
|
|
'command.backup:list', |
44
|
|
|
'command.backup:monitor', |
45
|
|
|
]); |
46
|
|
|
|
47
|
|
|
$this->app->singleton(ConsoleOutput::class); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
protected function handleDeprecatedConfigValues() |
51
|
|
|
{ |
52
|
|
|
$renamedConfigValues = [ |
53
|
|
|
|
54
|
|
|
/* |
55
|
|
|
* Earlier versions of the package used filesystems instead of disks |
56
|
|
|
*/ |
57
|
|
|
[ |
58
|
|
|
'oldName' => 'laravel-backup.backup.destination.filesystems', |
59
|
|
|
'newName' => 'laravel-backup.backup.destination.disks' |
60
|
|
|
], |
61
|
|
|
|
62
|
|
|
[ |
63
|
|
|
'oldName' => 'laravel-backup.monitorBackups.filesystems', |
64
|
|
|
'newName' => 'laravel-backup.monitorBackups.disks' |
65
|
|
|
], |
66
|
|
|
|
67
|
|
|
/* |
68
|
|
|
* Earlier versions of the package had a typo in the config value name |
69
|
|
|
*/ |
70
|
|
|
[ |
71
|
|
|
'oldName' => 'laravel-backup.notifications.whenUnHealthyBackupWasFound', |
72
|
|
|
'newName' => 'laravel-backup.notifications.whenUnhealthyBackupWasFound' |
73
|
|
|
], |
74
|
|
|
]; |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
foreach ($renamedConfigValues as $renamedConfigValue) { |
78
|
|
|
if (config($renamedConfigValue['oldName'])) { |
79
|
|
|
config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|