1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MedianetDev\BackpackForm; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
|
7
|
|
|
class AddonServiceProvider extends ServiceProvider |
8
|
|
|
{ |
9
|
|
|
use AutomaticServiceProvider; |
10
|
|
|
|
11
|
|
|
protected $vendorName = 'medianet-dev'; |
12
|
|
|
protected $packageName = 'backpack-form'; |
13
|
|
|
protected $commands = [ |
14
|
|
|
\MedianetDev\BackpackForm\Console\Commands\InitBackpackFormInstallation::class |
15
|
|
|
]; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Perform post-registration booting of services. |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function boot() |
23
|
|
|
{ |
24
|
|
|
if ( |
25
|
|
|
$this->packageDirectoryExistsAndIsNotEmpty('bootstrap') && |
26
|
|
|
file_exists($helpers = $this->packageHelpersFile()) |
27
|
|
|
) { |
28
|
|
|
require $helpers; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// Publishing the configuration file. |
32
|
|
|
if ($this->packageDirectoryExistsAndIsNotEmpty('config')) { |
33
|
|
|
$this->publishes([ |
34
|
|
|
$this->packageConfigFile() => $this->publishedConfigFile(), |
35
|
|
|
], 'config'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if ($this->packageDirectoryExistsAndIsNotEmpty('resources/lang')) { |
39
|
|
|
$this->loadTranslationsFrom($this->packageLangsPath(), $this->vendorNameDotPackageName()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
// if ($this->packageDirectoryExistsAndIsNotEmpty('resources/views')) { |
43
|
|
|
// // Load published views |
44
|
|
|
// $this->loadViewsFrom($this->publishedViewsPath(), $this->vendorNameDotPackageName()); |
45
|
|
|
|
46
|
|
|
// // Fallback to package views |
47
|
|
|
// $this->loadViewsFrom($this->packageViewsPath(), $this->vendorNameDotPackageName()); |
48
|
|
|
|
49
|
|
|
// } |
50
|
|
|
|
51
|
|
|
if ($this->packageDirectoryExistsAndIsNotEmpty('database/migrations')) { |
52
|
|
|
$this->loadMigrationsFrom($this->packageMigrationsPath()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ($this->packageDirectoryExistsAndIsNotEmpty('routes')) { |
56
|
|
|
$this->loadRoutesFrom($this->packageRoutesFile()); |
57
|
|
|
} |
58
|
|
|
// Load views |
59
|
|
|
$this->loadViewsFrom(dirname(__DIR__).'/resources/views', 'backpack-form'); |
60
|
|
|
|
61
|
|
|
// Register views for publishing |
62
|
|
|
$this->publishes([ |
63
|
|
|
dirname(__DIR__).'/resources/views/fields' => resource_path('views/vendor/backpack/crud/fields'), |
64
|
|
|
], 'views'); |
65
|
|
|
|
66
|
|
|
// Publishing is only necessary when using the CLI. |
67
|
|
|
if ($this->app->runningInConsole()) { |
68
|
|
|
$this->bootForConsole(); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Console-specific booting. |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
protected function bootForConsole(): void |
78
|
|
|
{ |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
// Publishing assets. |
85
|
|
|
if ($this->packageDirectoryExistsAndIsNotEmpty('resources/assets')) { |
86
|
|
|
$this->publishes([ |
87
|
|
|
$this->packageAssetsPath() => $this->publishedAssetsPath(), |
88
|
|
|
], 'assets'); |
89
|
|
|
} |
90
|
|
|
// if ($this->packageDirectoryExistsAndIsNotEmpty('resources/views')) { |
91
|
|
|
// $this->publishes([ |
92
|
|
|
// $this->packageViewsPath() => $this->publishedViewsPath(), |
93
|
|
|
// ], 'views'); |
94
|
|
|
// } |
95
|
|
|
|
96
|
|
|
// Registering package commands. |
97
|
|
|
if (!empty($this->commands)) { |
98
|
|
|
$this->commands($this->commands); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
// register command for installation and other |
102
|
|
|
public function register() |
103
|
|
|
{ |
104
|
|
|
$this->commands($this->commands); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|