1
|
|
|
<?php namespace Jawaraegov\Workflows; |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\ServiceProvider; |
4
|
|
|
use Jawaraegov\Workflows\Console\Commands\WorkflowCommand; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* The WorkflowServiceProvider class |
8
|
|
|
* |
9
|
|
|
* @package Jawaraegov\Workflows |
10
|
|
|
* @author Jawaraegov <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class WorkflowServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Indicates if loading of the provider is deferred. |
17
|
|
|
* |
18
|
|
|
* @var bool |
19
|
|
|
*/ |
20
|
|
|
protected $defer = false; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Bootstrap the application events. |
24
|
|
|
* |
25
|
|
|
* @return void |
26
|
|
|
*/ |
27
|
|
|
public function boot() |
28
|
|
|
{ |
29
|
|
|
// Bootstrap handles |
30
|
|
|
$this->routeHandle(); |
31
|
|
|
$this->configHandle(); |
32
|
|
|
$this->langHandle(); |
33
|
|
|
$this->viewHandle(); |
34
|
|
|
$this->assetHandle(); |
35
|
|
|
$this->migrationHandle(); |
36
|
|
|
$this->cssHandle(); |
37
|
|
|
$this->jsHandle(); |
38
|
|
|
$this->commands('Jawaraegov\Workflows\Console\Commands\SeedCommand'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register the service provider. |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
public function register() |
47
|
|
|
{ |
48
|
|
|
$this->app->singleton('workflow', function ($app) { |
|
|
|
|
49
|
|
|
return new Workflow; |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
$this->app->singleton('command.workflow', function ($app) { |
|
|
|
|
53
|
|
|
return new WorkflowCommand; |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
$this->commands('command.workflow'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get the services provided by the provider. |
61
|
|
|
* |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
public function provides() |
65
|
|
|
{ |
66
|
|
|
return [ |
67
|
|
|
'workflow', |
68
|
|
|
'command.workflow', |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Loading package routes |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
protected function routeHandle() |
78
|
|
|
{ |
79
|
|
|
$this->loadRoutesFrom(__DIR__.'/routes/routes.php'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Loading and publishing package's config |
84
|
|
|
* |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
|
|
protected function configHandle() |
88
|
|
|
{ |
89
|
|
|
$packageConfigPath = __DIR__.'/config/config.php'; |
90
|
|
|
$appConfigPath = config_path('workflow.php'); |
91
|
|
|
|
92
|
|
|
$this->mergeConfigFrom($packageConfigPath, 'workflow'); |
93
|
|
|
|
94
|
|
|
$this->publishes([ |
95
|
|
|
$packageConfigPath => $appConfigPath, |
96
|
|
|
], 'config'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Loading and publishing package's translations |
101
|
|
|
* |
102
|
|
|
* @return void |
103
|
|
|
*/ |
104
|
|
|
protected function langHandle() |
105
|
|
|
{ |
106
|
|
|
$packageTranslationsPath = __DIR__.'/resources/lang'; |
107
|
|
|
|
108
|
|
|
$this->loadTranslationsFrom($packageTranslationsPath, 'workflow'); |
109
|
|
|
|
110
|
|
|
$this->publishes([ |
111
|
|
|
$packageTranslationsPath => resource_path('lang/vendor/workflow'), |
112
|
|
|
], 'lang'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Loading and publishing package's views |
117
|
|
|
* |
118
|
|
|
* @return void |
119
|
|
|
*/ |
120
|
|
|
protected function viewHandle() |
121
|
|
|
{ |
122
|
|
|
$packageViewsPath = __DIR__.'/resources/views'; |
123
|
|
|
|
124
|
|
|
$this->loadViewsFrom($packageViewsPath, 'workflow'); |
125
|
|
|
|
126
|
|
|
$this->publishes([ |
127
|
|
|
$packageViewsPath => resource_path('views/'), |
128
|
|
|
], 'workflow_views'); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Publishing package's assets (JavaScript, CSS, images...) |
133
|
|
|
* |
134
|
|
|
* @return void |
135
|
|
|
*/ |
136
|
|
|
protected function assetHandle() |
137
|
|
|
{ |
138
|
|
|
$packageAssetsPath = __DIR__.'/resources/assets'; |
139
|
|
|
|
140
|
|
|
$this->publishes([ |
141
|
|
|
$packageAssetsPath => public_path('vendor/workflow'), |
142
|
|
|
], 'public'); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Publishing package's migrations |
147
|
|
|
* |
148
|
|
|
* @return void |
149
|
|
|
*/ |
150
|
|
|
protected function migrationHandle() |
151
|
|
|
{ |
152
|
|
|
$packageMigrationsPath = __DIR__.'/database/migrations'; |
153
|
|
|
|
154
|
|
|
$this->loadMigrationsFrom($packageMigrationsPath); |
155
|
|
|
|
156
|
|
|
$this->publishes([ |
157
|
|
|
$packageMigrationsPath => database_path('migrations') |
158
|
|
|
], 'workflow_migrations'); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function cssHandle() |
162
|
|
|
{ |
163
|
|
|
$packageMigrationsPath = __DIR__.'/public/css'; |
164
|
|
|
|
165
|
|
|
$this->publishes([ |
166
|
|
|
$packageMigrationsPath => base_path('public/css') |
167
|
|
|
], 'workflow_css'); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function jsHandle() |
171
|
|
|
{ |
172
|
|
|
$packageMigrationsPath = __DIR__.'/public/js'; |
173
|
|
|
|
174
|
|
|
$this->publishes([ |
175
|
|
|
$packageMigrationsPath => base_path('public/js') |
176
|
|
|
], 'workflow_js'); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.