|
1
|
|
|
<?php
|
|
2
|
|
|
|
|
3
|
|
|
namespace Nwidart\Modules;
|
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
6
|
|
|
use Nwidart\Modules\Providers\BootstrapServiceProvider;
|
|
7
|
|
|
use Nwidart\Modules\Providers\ConsoleServiceProvider;
|
|
8
|
|
|
use Nwidart\Modules\Providers\ContractsServiceProvider;
|
|
9
|
|
|
|
|
10
|
|
|
abstract class ModulesServiceProvider extends ServiceProvider
|
|
11
|
|
|
{
|
|
12
|
|
|
/**
|
|
13
|
|
|
* Indicates if loading of the provider is deferred.
|
|
14
|
|
|
*
|
|
15
|
|
|
* @var bool
|
|
16
|
|
|
*/
|
|
17
|
|
|
protected $defer = false;
|
|
18
|
|
|
|
|
19
|
|
|
/**
|
|
20
|
|
|
* Booting the package.
|
|
21
|
|
|
*/
|
|
22
|
|
|
public function boot()
|
|
23
|
|
|
{
|
|
24
|
|
|
}
|
|
25
|
|
|
|
|
26
|
|
|
/**
|
|
27
|
|
|
* Register all modules.
|
|
28
|
|
|
*/
|
|
29
|
|
|
public function register()
|
|
30
|
|
|
{
|
|
31
|
|
|
}
|
|
32
|
|
|
|
|
33
|
|
|
/**
|
|
34
|
|
|
* Register all modules.
|
|
35
|
|
|
*/
|
|
36
|
111 |
|
protected function registerModules()
|
|
37
|
|
|
{
|
|
38
|
111 |
|
$this->app->register(BootstrapServiceProvider::class);
|
|
39
|
111 |
|
}
|
|
40
|
|
|
|
|
41
|
|
|
/**
|
|
42
|
|
|
* Register package's namespaces.
|
|
43
|
|
|
*/
|
|
44
|
111 |
|
protected function registerNamespaces()
|
|
45
|
|
|
{
|
|
46
|
111 |
|
$configPath = __DIR__ . '/../config/config.php';
|
|
47
|
|
|
|
|
48
|
111 |
|
$this->mergeConfigFrom($configPath, 'modules');
|
|
49
|
111 |
|
$this->publishes([
|
|
50
|
111 |
|
$configPath => config_path('modules.php'),
|
|
51
|
111 |
|
], 'config');
|
|
52
|
111 |
|
}
|
|
53
|
|
|
|
|
54
|
|
|
/**
|
|
55
|
|
|
* Register the service provider.
|
|
56
|
|
|
*/
|
|
57
|
|
|
protected function registerServices()
|
|
58
|
|
|
{
|
|
59
|
111 |
|
$this->app->singleton('modules', function ($app) {
|
|
60
|
111 |
|
$path = $app['config']->get('modules.paths.modules');
|
|
61
|
|
|
|
|
62
|
111 |
|
return new Repository($app, $path);
|
|
63
|
111 |
|
});
|
|
64
|
111 |
|
}
|
|
65
|
|
|
|
|
66
|
|
|
/**
|
|
67
|
|
|
* Get the services provided by the provider.
|
|
68
|
|
|
*
|
|
69
|
|
|
* @return array
|
|
70
|
|
|
*/
|
|
71
|
|
|
public function provides()
|
|
72
|
|
|
{
|
|
73
|
|
|
return ['modules'];
|
|
74
|
|
|
}
|
|
75
|
|
|
|
|
76
|
|
|
/**
|
|
77
|
|
|
* Register providers.
|
|
78
|
|
|
*/
|
|
79
|
111 |
|
protected function registerProviders()
|
|
80
|
|
|
{
|
|
81
|
111 |
|
$this->app->register(ConsoleServiceProvider::class);
|
|
82
|
111 |
|
$this->app->register(ContractsServiceProvider::class);
|
|
83
|
111 |
|
}
|
|
84
|
|
|
}
|
|
85
|
|
|
|