1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\BackupManager; |
4
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class BackupManagerServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Indicates if loading of the provider is deferred. |
12
|
|
|
* |
13
|
|
|
* @var bool |
14
|
|
|
*/ |
15
|
|
|
protected $defer = false; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Where the route file lives, both inside the package and in the app (if overwritten). |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
public $routeFilePath = '/routes/backpack/backupmanager.php'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Perform post-registration booting of services. |
26
|
|
|
* |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
|
public function boot() |
30
|
|
|
{ |
31
|
|
|
// use the vendor configuration file as fallback |
32
|
|
|
$this->mergeConfigFrom( |
33
|
|
|
__DIR__.'/config/backup.php', 'backpack.backupmanager' |
34
|
|
|
); |
35
|
|
|
|
36
|
|
|
// LOAD THE VIEWS |
37
|
|
|
// - first the published/overwritten views (in case they have any changes) |
38
|
|
|
$this->loadViewsFrom(resource_path('views/vendor/backpack/backupmanager'), 'backupmanager'); |
39
|
|
|
// - then the stock views that come with the package, in case a published view might be missing |
40
|
|
|
$this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'backupmanager'); |
41
|
|
|
|
42
|
|
|
// load translation |
43
|
|
|
$this->loadTranslationsFrom(resource_path('lang/vendor/backpack'), 'backpack'); |
44
|
|
|
$this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack'); |
45
|
|
|
|
46
|
|
|
// publish config file |
47
|
|
|
$this->publishes([__DIR__.'/config/backup.php' => config_path('backup.php')], 'config'); |
48
|
|
|
// publish lang files |
49
|
|
|
$this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang'); |
50
|
|
|
// publish the views |
51
|
|
|
$this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/backupmanager')], 'views'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Define the routes for the application. |
56
|
|
|
* |
57
|
|
|
* @param \Illuminate\Routing\Router $router |
58
|
|
|
* |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
public function setupRoutes(Router $router) |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
// by default, use the routes file provided in vendor |
64
|
|
|
$routeFilePathInUse = __DIR__.$this->routeFilePath; |
65
|
|
|
|
66
|
|
|
// but if there's a file with the same name in routes/backpack, use that one |
67
|
|
|
if (file_exists(base_path().$this->routeFilePath)) { |
68
|
|
|
$routeFilePathInUse = base_path().$this->routeFilePath; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$this->loadRoutesFrom($routeFilePathInUse); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Register any package services. |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function register() |
80
|
|
|
{ |
81
|
|
|
$this->setupRoutes($this->app->router); |
|
|
|
|
82
|
|
|
|
83
|
|
|
// use this if your package has a config file |
84
|
|
|
config([ |
85
|
|
|
'config/backup.php', |
86
|
|
|
]); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.