1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelModulize\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
6
|
|
|
use Illuminate\Filesystem\Filesystem; |
7
|
|
|
use LaravelModulize\Services\Modulizer; |
8
|
|
|
use LaravelModulize\Services\ModulizerRepository; |
9
|
|
|
use LaravelModulize\Contracts\ModulizerRepositoryInterface; |
10
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Service provider |
14
|
|
|
*/ |
15
|
|
|
class ModulizeServiceProvider extends BaseServiceProvider |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Bootstrap the application services. |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function boot() |
23
|
|
|
{ |
24
|
|
|
$this->app->get('modulizer')->bootstrapFileLoaders(); |
25
|
|
|
|
26
|
|
|
$this->loadMigrationsFrom($this->app->get(ModulizerRepository::class)->migrations); |
27
|
|
|
|
28
|
|
|
$this->loadTranslations( |
29
|
|
|
collect($this->app->get(ModulizerRepository::class)->translations) |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
$this->publishes([ |
33
|
|
|
$this->getDefaultConfigFilePath('modulizer') => config_path('modulizer.php'), |
34
|
|
|
], 'config'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Register the application services. |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
public function register() |
43
|
|
|
{ |
44
|
|
|
$this->app->singleton(ModulizerRepository::class, function ($app) { |
|
|
|
|
45
|
|
|
return new ModulizerRepository(new Filesystem()); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
$this->app->bind( |
49
|
|
|
ModulizerRepositoryInterface::class, |
50
|
|
|
ModulizerRepository::class |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
$this->app->singleton('modulizer', function ($app) { |
54
|
|
|
return $app->make(Modulizer::class); |
55
|
|
|
}); |
56
|
|
|
|
57
|
|
|
$this->mergeConfigFrom( |
58
|
|
|
$this->getDefaultConfigFilePath('modulizer'), 'modulizer' |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get default configuration file path |
64
|
|
|
* |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getDefaultConfigFilePath($configName) |
68
|
|
|
{ |
69
|
|
|
return realpath(__DIR__ . "/../config/{$configName}.php"); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
protected function loadTranslations(Collection $translations) |
73
|
|
|
{ |
74
|
|
|
$translations->each(function ($translationsFile) { |
75
|
|
|
$this->loadTranslationsFrom( |
76
|
|
|
$translationsFile->path, |
77
|
|
|
$translationsFile->namespace |
78
|
|
|
); |
79
|
|
|
}); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.