|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Distilleries\Expendable; |
|
4
|
|
|
|
|
5
|
|
|
use Distilleries\Expendable\Layouts\LayoutManager; |
|
6
|
|
|
use Distilleries\Expendable\Models\User; |
|
7
|
|
|
use Distilleries\Expendable\States\StateDisplayer; |
|
8
|
|
|
use Illuminate\Support\ServiceProvider; |
|
9
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
10
|
|
|
|
|
11
|
|
|
class ExpendableServiceProvider extends ServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Indicates if loading of the provider is deferred. |
|
15
|
|
|
* |
|
16
|
|
|
* @var bool |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $defer = true; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Bootstrap the application events. |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
286 |
|
public function boot() |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
286 |
|
$this->loadViewsFrom(__DIR__ . '/../../views', 'expendable'); |
|
29
|
286 |
|
$this->loadTranslationsFrom(__DIR__ . '/../../lang', 'expendable'); |
|
30
|
286 |
|
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations/'); |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
286 |
|
$this->publishes([ |
|
34
|
286 |
|
__DIR__ . '/../../config/config.php' => config_path('expendable.php'), |
|
35
|
286 |
|
__DIR__ . '/../../database/seeds/' => base_path('/database/seeds'), |
|
36
|
|
|
]); |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
286 |
|
$this->publishes([ |
|
40
|
286 |
|
__DIR__ . '/../../views' => base_path('resources/views/vendor/expendable'), |
|
41
|
286 |
|
], 'views'); |
|
42
|
286 |
|
$this->mergeConfigFrom( |
|
43
|
286 |
|
__DIR__ . '/../../config/config.php', 'expendable' |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
286 |
|
$autoLoaderListener = new \Distilleries\Expendable\Register\ListenerAutoLoader(config('expendable.listener')); |
|
47
|
286 |
|
$autoLoaderListener->load(); |
|
48
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Register the service provider. |
|
53
|
|
|
* |
|
54
|
|
|
* @return void |
|
55
|
|
|
*/ |
|
56
|
286 |
|
public function register() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->app->singleton('Distilleries\Expendable\Contracts\LockableContract', function($app) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
4 |
|
return new User; |
|
61
|
286 |
|
}); |
|
62
|
|
|
|
|
63
|
|
|
$this->app->singleton('Distilleries\Expendable\Contracts\StateDisplayerContract', function($app) |
|
64
|
|
|
{ |
|
65
|
150 |
|
return new StateDisplayer($app['view'], $app['config']->get('expendable')); |
|
66
|
286 |
|
}); |
|
67
|
|
|
|
|
68
|
|
|
$this->app->singleton('Distilleries\Expendable\Contracts\LayoutManagerContract', function($app) |
|
69
|
|
|
{ |
|
70
|
148 |
|
return new LayoutManager($app['config']->get('expendable'), $app['view'], $app['files'], app('Distilleries\Expendable\Contracts\StateDisplayerContract')); |
|
71
|
286 |
|
}); |
|
72
|
|
|
|
|
73
|
286 |
|
$this->alias(); |
|
74
|
286 |
|
$this->registerCommands(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
286 |
|
protected function registerCommands() |
|
78
|
|
|
{ |
|
79
|
286 |
|
$file = app('files'); |
|
80
|
286 |
|
$files = $file->allFiles(__DIR__ . '/Console/'); |
|
81
|
|
|
|
|
82
|
286 |
|
foreach ($files as $file) |
|
83
|
|
|
{ |
|
84
|
286 |
|
if (strpos($file->getPathName(), 'Lib') === false) |
|
85
|
|
|
{ |
|
86
|
286 |
|
$this->commands('Distilleries\Expendable\Console\\' . preg_replace('/\.php/i', '', $file->getFilename())); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
8 |
|
public function provides() |
|
92
|
|
|
{ |
|
93
|
|
|
return [ |
|
94
|
8 |
|
'Distilleries\Expendable\Contracts\StateDisplayerContract', |
|
95
|
|
|
'Distilleries\Expendable\Contracts\LayoutManagerContract', |
|
96
|
|
|
'Distilleries\Expendable\Contracts\ImportContract', |
|
97
|
|
|
'Distilleries\Expendable\Contracts\ExportContract', |
|
98
|
|
|
]; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
286 |
|
public function alias() |
|
103
|
|
|
{ |
|
104
|
|
|
|
|
105
|
286 |
|
AliasLoader::getInstance()->alias( |
|
106
|
286 |
|
'Excel', |
|
107
|
286 |
|
'Maatwebsite\Excel\Facades\Excel' |
|
108
|
|
|
); |
|
109
|
|
|
} |
|
110
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.