|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Cortex\Foundation\Providers; |
|
6
|
|
|
|
|
7
|
|
|
use Cortex\Foundation\Console\Commands\ServeCommand; |
|
8
|
|
|
use Illuminate\Console\Scheduling\ScheduleRunCommand; |
|
9
|
|
|
use Cortex\Foundation\Console\Commands\JobMakeCommand; |
|
10
|
|
|
use Cortex\Foundation\Console\Commands\MailMakeCommand; |
|
11
|
|
|
use Cortex\Foundation\Console\Commands\RuleMakeCommand; |
|
12
|
|
|
use Cortex\Foundation\Console\Commands\EventMakeCommand; |
|
13
|
|
|
use Cortex\Foundation\Console\Commands\ModelMakeCommand; |
|
14
|
|
|
use Illuminate\Console\Scheduling\ScheduleFinishCommand; |
|
15
|
|
|
use Cortex\Foundation\Console\Commands\ConfigMakeCommand; |
|
16
|
|
|
use Cortex\Foundation\Console\Commands\ModuleMakeCommand; |
|
17
|
|
|
use Cortex\Foundation\Console\Commands\PolicyMakeCommand; |
|
18
|
|
|
use Cortex\Foundation\Console\Commands\SeederMakeCommand; |
|
19
|
|
|
use Cortex\Foundation\Console\Commands\ChannelMakeCommand; |
|
20
|
|
|
use Cortex\Foundation\Console\Commands\ConsoleMakeCommand; |
|
21
|
|
|
use Cortex\Foundation\Console\Commands\FactoryMakeCommand; |
|
22
|
|
|
use Cortex\Foundation\Console\Commands\MigrateMakeCommand; |
|
23
|
|
|
use Cortex\Foundation\Console\Commands\RequestMakeCommand; |
|
24
|
|
|
use Cortex\Foundation\Console\Commands\ListenerMakeCommand; |
|
25
|
|
|
use Cortex\Foundation\Console\Commands\ProviderMakeCommand; |
|
26
|
|
|
use Cortex\Foundation\Console\Commands\ResourceMakeCommand; |
|
27
|
|
|
use Cortex\Foundation\Console\Commands\DataTableMakeCommand; |
|
28
|
|
|
use Cortex\Foundation\Console\Commands\EventGenerateCommand; |
|
29
|
|
|
use Cortex\Foundation\Console\Commands\ExceptionMakeCommand; |
|
30
|
|
|
use Cortex\Foundation\Console\Commands\VendorPublishCommand; |
|
31
|
|
|
use Cortex\Foundation\Console\Commands\ControllerMakeCommand; |
|
32
|
|
|
use Cortex\Foundation\Console\Commands\MiddlewareMakeCommand; |
|
33
|
|
|
use Cortex\Foundation\Console\Commands\TransformerMakeCommand; |
|
34
|
|
|
use Cortex\Foundation\Console\Commands\NotificationMakeCommand; |
|
35
|
|
|
use Illuminate\Foundation\Providers\ArtisanServiceProvider as BaseArtisanServiceProvider; |
|
36
|
|
|
|
|
37
|
|
|
class ArtisanServiceProvider extends BaseArtisanServiceProvider |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* Indicates if loading of the provider is deferred. |
|
41
|
|
|
* |
|
42
|
|
|
* @var bool |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $defer = true; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* The commands to be registered. |
|
48
|
|
|
* |
|
49
|
|
|
* @var array |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $commands = [ |
|
52
|
|
|
'CacheClear' => 'command.cache.clear', |
|
53
|
|
|
'CacheForget' => 'command.cache.forget', |
|
54
|
|
|
'ClearCompiled' => 'command.clear-compiled', |
|
55
|
|
|
//'ClearResets' => 'command.auth.resets.clear', |
|
56
|
|
|
'ConfigCache' => 'command.config.cache', |
|
57
|
|
|
'ConfigClear' => 'command.config.clear', |
|
58
|
|
|
'Down' => 'command.down', |
|
59
|
|
|
'Environment' => 'command.environment', |
|
60
|
|
|
'KeyGenerate' => 'command.key.generate', |
|
61
|
|
|
'Migrate' => 'command.migrate', |
|
62
|
|
|
'MigrateFresh' => 'command.migrate.fresh', |
|
63
|
|
|
'MigrateInstall' => 'command.migrate.install', |
|
64
|
|
|
'MigrateRefresh' => 'command.migrate.refresh', |
|
65
|
|
|
'MigrateReset' => 'command.migrate.reset', |
|
66
|
|
|
'MigrateRollback' => 'command.migrate.rollback', |
|
67
|
|
|
'MigrateStatus' => 'command.migrate.status', |
|
68
|
|
|
'PackageDiscover' => 'command.package.discover', |
|
69
|
|
|
'Preset' => 'command.preset', |
|
70
|
|
|
'QueueFailed' => 'command.queue.failed', |
|
71
|
|
|
'QueueFlush' => 'command.queue.flush', |
|
72
|
|
|
'QueueForget' => 'command.queue.forget', |
|
73
|
|
|
'QueueListen' => 'command.queue.listen', |
|
74
|
|
|
'QueueRestart' => 'command.queue.restart', |
|
75
|
|
|
'QueueRetry' => 'command.queue.retry', |
|
76
|
|
|
'QueueWork' => 'command.queue.work', |
|
77
|
|
|
'RouteCache' => 'command.route.cache', |
|
78
|
|
|
'RouteClear' => 'command.route.clear', |
|
79
|
|
|
'RouteList' => 'command.route.list', |
|
80
|
|
|
'Seed' => 'command.seed', |
|
81
|
|
|
'ScheduleFinish' => ScheduleFinishCommand::class, |
|
82
|
|
|
'ScheduleRun' => ScheduleRunCommand::class, |
|
83
|
|
|
'StorageLink' => 'command.storage.link', |
|
84
|
|
|
'Up' => 'command.up', |
|
85
|
|
|
'ViewClear' => 'command.view.clear', |
|
86
|
|
|
]; |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* The commands to be registered. |
|
90
|
|
|
* |
|
91
|
|
|
* @var array |
|
92
|
|
|
*/ |
|
93
|
|
|
protected $devCommands = [ |
|
94
|
|
|
//'AppName' => 'command.app.name', |
|
95
|
|
|
//'AuthMake' => 'command.auth.make', |
|
96
|
|
|
//'CacheTable' => 'command.cache.table', |
|
97
|
|
|
'ConfigMake' => 'command.config.make', |
|
98
|
|
|
'ChannelMake' => 'command.channel.make', |
|
99
|
|
|
'ConsoleMake' => 'command.console.make', |
|
100
|
|
|
'ControllerMake' => 'command.controller.make', |
|
101
|
|
|
'DatatableMake' => 'command.datatable.make', |
|
102
|
|
|
'EventGenerate' => 'command.event.generate', |
|
103
|
|
|
'EventMake' => 'command.event.make', |
|
104
|
|
|
'ExceptionMake' => 'command.exception.make', |
|
105
|
|
|
'FactoryMake' => 'command.factory.make', |
|
106
|
|
|
'JobMake' => 'command.job.make', |
|
107
|
|
|
'ListenerMake' => 'command.listener.make', |
|
108
|
|
|
'MailMake' => 'command.mail.make', |
|
109
|
|
|
'MiddlewareMake' => 'command.middleware.make', |
|
110
|
|
|
'MigrateMake' => 'command.migrate.make', |
|
111
|
|
|
'ModelMake' => 'command.model.make', |
|
112
|
|
|
'ModuleMake' => 'command.module.make', |
|
113
|
|
|
'NotificationMake' => 'command.notification.make', |
|
114
|
|
|
//'NotificationTable' => 'command.notification.table', |
|
115
|
|
|
'PolicyMake' => 'command.policy.make', |
|
116
|
|
|
'ProviderMake' => 'command.provider.make', |
|
117
|
|
|
//'QueueFailedTable' => 'command.queue.failed-table', |
|
118
|
|
|
//'QueueTable' => 'command.queue.table', |
|
119
|
|
|
'RequestMake' => 'command.request.make', |
|
120
|
|
|
'ResourceMake' => 'command.resource.make', |
|
121
|
|
|
'RuleMake' => 'command.rule.make', |
|
122
|
|
|
'SeederMake' => 'command.seeder.make', |
|
123
|
|
|
//'SessionTable' => 'command.session.table', |
|
124
|
|
|
'Serve' => 'command.serve', |
|
125
|
|
|
'TestMake' => 'command.test.make', |
|
126
|
|
|
'TransformerMake' => 'command.transformer.make', |
|
127
|
|
|
'VendorPublish' => 'command.vendor.publish', |
|
128
|
|
|
]; |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Register the service provider. |
|
132
|
|
|
* |
|
133
|
|
|
* @return void |
|
134
|
|
|
*/ |
|
135
|
|
|
public function register(): void |
|
136
|
|
|
{ |
|
137
|
|
|
! $this->app->runningInConsole() || $this->registerCommands($this->commands); |
|
138
|
|
|
! $this->app->runningInConsole() || $this->registerCommands($this->devCommands); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Register the command. |
|
143
|
|
|
* |
|
144
|
|
|
* @return void |
|
145
|
|
|
*/ |
|
146
|
|
|
protected function registerConfigMakeCommand(): void |
|
147
|
|
|
{ |
|
148
|
|
|
$this->app->singleton('command.config.make', function ($app) { |
|
149
|
|
|
return new ConfigMakeCommand($app['files']); |
|
150
|
|
|
}); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Register the command. |
|
155
|
|
|
* |
|
156
|
|
|
* @return void |
|
157
|
|
|
*/ |
|
158
|
|
|
protected function registerChannelMakeCommand() |
|
159
|
|
|
{ |
|
160
|
|
|
$this->app->singleton('command.channel.make', function ($app) { |
|
161
|
|
|
return new ChannelMakeCommand($app['files']); |
|
162
|
|
|
}); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Register the command. |
|
167
|
|
|
* |
|
168
|
|
|
* @return void |
|
169
|
|
|
*/ |
|
170
|
|
|
protected function registerConsoleMakeCommand(): void |
|
171
|
|
|
{ |
|
172
|
|
|
$this->app->singleton('command.console.make', function ($app) { |
|
173
|
|
|
return new ConsoleMakeCommand($app['files']); |
|
174
|
|
|
}); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Register the command. |
|
179
|
|
|
* |
|
180
|
|
|
* @return void |
|
181
|
|
|
*/ |
|
182
|
|
|
protected function registerEventGenerateCommand() |
|
183
|
|
|
{ |
|
184
|
|
|
$this->app->singleton('command.event.generate', function () { |
|
185
|
|
|
return new EventGenerateCommand(); |
|
186
|
|
|
}); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Register the command. |
|
191
|
|
|
* |
|
192
|
|
|
* @return void |
|
193
|
|
|
*/ |
|
194
|
|
|
protected function registerControllerMakeCommand(): void |
|
195
|
|
|
{ |
|
196
|
|
|
$this->app->singleton('command.controller.make', function ($app) { |
|
197
|
|
|
return new ControllerMakeCommand($app['files']); |
|
198
|
|
|
}); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Register the command. |
|
203
|
|
|
* |
|
204
|
|
|
* @return void |
|
205
|
|
|
*/ |
|
206
|
|
|
protected function registerDatatableMakeCommand(): void |
|
207
|
|
|
{ |
|
208
|
|
|
$this->app->singleton('command.datatable.make', function ($app) { |
|
209
|
|
|
return new DataTableMakeCommand($app['files']); |
|
210
|
|
|
}); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* Register the command. |
|
215
|
|
|
* |
|
216
|
|
|
* @return void |
|
217
|
|
|
*/ |
|
218
|
|
|
protected function registerEventMakeCommand(): void |
|
219
|
|
|
{ |
|
220
|
|
|
$this->app->singleton('command.event.make', function ($app) { |
|
221
|
|
|
return new EventMakeCommand($app['files']); |
|
222
|
|
|
}); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Register the command. |
|
227
|
|
|
* |
|
228
|
|
|
* @return void |
|
229
|
|
|
*/ |
|
230
|
|
|
protected function registerExceptionMakeCommand() |
|
231
|
|
|
{ |
|
232
|
|
|
$this->app->singleton('command.exception.make', function ($app) { |
|
233
|
|
|
return new ExceptionMakeCommand($app['files']); |
|
234
|
|
|
}); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* Register the command. |
|
239
|
|
|
* |
|
240
|
|
|
* @return void |
|
241
|
|
|
*/ |
|
242
|
|
|
protected function registerFactoryMakeCommand(): void |
|
243
|
|
|
{ |
|
244
|
|
|
$this->app->singleton('command.factory.make', function ($app) { |
|
245
|
|
|
return new FactoryMakeCommand($app['files']); |
|
246
|
|
|
}); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Register the command. |
|
251
|
|
|
* |
|
252
|
|
|
* @return void |
|
253
|
|
|
*/ |
|
254
|
|
|
protected function registerJobMakeCommand(): void |
|
255
|
|
|
{ |
|
256
|
|
|
$this->app->singleton('command.job.make', function ($app) { |
|
257
|
|
|
return new JobMakeCommand($app['files']); |
|
258
|
|
|
}); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* Register the command. |
|
263
|
|
|
* |
|
264
|
|
|
* @return void |
|
265
|
|
|
*/ |
|
266
|
|
|
protected function registerListenerMakeCommand(): void |
|
267
|
|
|
{ |
|
268
|
|
|
$this->app->singleton('command.listener.make', function ($app) { |
|
269
|
|
|
return new ListenerMakeCommand($app['files']); |
|
270
|
|
|
}); |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* Register the command. |
|
275
|
|
|
* |
|
276
|
|
|
* @return void |
|
277
|
|
|
*/ |
|
278
|
|
|
protected function registerMailMakeCommand(): void |
|
279
|
|
|
{ |
|
280
|
|
|
$this->app->singleton('command.mail.make', function ($app) { |
|
281
|
|
|
return new MailMakeCommand($app['files']); |
|
282
|
|
|
}); |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* Register the command. |
|
287
|
|
|
* |
|
288
|
|
|
* @return void |
|
289
|
|
|
*/ |
|
290
|
|
|
protected function registerMiddlewareMakeCommand(): void |
|
291
|
|
|
{ |
|
292
|
|
|
$this->app->singleton('command.middleware.make', function ($app) { |
|
293
|
|
|
return new MiddlewareMakeCommand($app['files']); |
|
294
|
|
|
}); |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* Register the command. |
|
299
|
|
|
* |
|
300
|
|
|
* @return void |
|
301
|
|
|
*/ |
|
302
|
|
|
protected function registerMigrateMakeCommand(): void |
|
303
|
|
|
{ |
|
304
|
|
|
$this->app->singleton('command.migrate.make', function ($app) { |
|
305
|
|
|
// Once we have the migration creator registered, we will create the command |
|
306
|
|
|
// and inject the creator. The creator is responsible for the actual file |
|
307
|
|
|
// creation of the migrations, and may be extended by these developers. |
|
308
|
|
|
$creator = $app['migration.creator']; |
|
309
|
|
|
|
|
310
|
|
|
$composer = $app['composer']; |
|
311
|
|
|
|
|
312
|
|
|
return new MigrateMakeCommand($creator, $composer); |
|
313
|
|
|
}); |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
|
|
/** |
|
317
|
|
|
* Register the command. |
|
318
|
|
|
* |
|
319
|
|
|
* @return void |
|
320
|
|
|
*/ |
|
321
|
|
|
protected function registerModelMakeCommand(): void |
|
322
|
|
|
{ |
|
323
|
|
|
$this->app->singleton('command.model.make', function ($app) { |
|
324
|
|
|
return new ModelMakeCommand($app['files']); |
|
325
|
|
|
}); |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* Register the command. |
|
330
|
|
|
* |
|
331
|
|
|
* @return void |
|
332
|
|
|
*/ |
|
333
|
|
|
protected function registerModuleMakeCommand(): void |
|
334
|
|
|
{ |
|
335
|
|
|
$this->app->singleton('command.module.make', function ($app) { |
|
336
|
|
|
return new ModuleMakeCommand($app['files']); |
|
337
|
|
|
}); |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* Register the command. |
|
342
|
|
|
* |
|
343
|
|
|
* @return void |
|
344
|
|
|
*/ |
|
345
|
|
|
protected function registerNotificationMakeCommand(): void |
|
346
|
|
|
{ |
|
347
|
|
|
$this->app->singleton('command.notification.make', function ($app) { |
|
348
|
|
|
return new NotificationMakeCommand($app['files']); |
|
349
|
|
|
}); |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* Register the command. |
|
354
|
|
|
* |
|
355
|
|
|
* @return void |
|
356
|
|
|
*/ |
|
357
|
|
|
protected function registerPolicyMakeCommand(): void |
|
358
|
|
|
{ |
|
359
|
|
|
$this->app->singleton('command.policy.make', function ($app) { |
|
360
|
|
|
return new PolicyMakeCommand($app['files']); |
|
361
|
|
|
}); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* Register the command. |
|
366
|
|
|
* |
|
367
|
|
|
* @return void |
|
368
|
|
|
*/ |
|
369
|
|
|
protected function registerProviderMakeCommand(): void |
|
370
|
|
|
{ |
|
371
|
|
|
$this->app->singleton('command.provider.make', function ($app) { |
|
372
|
|
|
return new ProviderMakeCommand($app['files']); |
|
373
|
|
|
}); |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* Register the command. |
|
378
|
|
|
* |
|
379
|
|
|
* @return void |
|
380
|
|
|
*/ |
|
381
|
|
|
protected function registerRequestMakeCommand(): void |
|
382
|
|
|
{ |
|
383
|
|
|
$this->app->singleton('command.request.make', function ($app) { |
|
384
|
|
|
return new RequestMakeCommand($app['files']); |
|
385
|
|
|
}); |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
/** |
|
389
|
|
|
* Register the command. |
|
390
|
|
|
* |
|
391
|
|
|
* @return void |
|
392
|
|
|
*/ |
|
393
|
|
|
protected function registerResourceMakeCommand(): void |
|
394
|
|
|
{ |
|
395
|
|
|
$this->app->singleton('command.resource.make', function ($app) { |
|
396
|
|
|
return new ResourceMakeCommand($app['files']); |
|
397
|
|
|
}); |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
/** |
|
401
|
|
|
* Register the command. |
|
402
|
|
|
* |
|
403
|
|
|
* @return void |
|
404
|
|
|
*/ |
|
405
|
|
|
protected function registerRuleMakeCommand(): void |
|
406
|
|
|
{ |
|
407
|
|
|
$this->app->singleton('command.rule.make', function ($app) { |
|
408
|
|
|
return new RuleMakeCommand($app['files']); |
|
409
|
|
|
}); |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
/** |
|
413
|
|
|
* Register the command. |
|
414
|
|
|
* |
|
415
|
|
|
* @return void |
|
416
|
|
|
*/ |
|
417
|
|
|
protected function registerSeederMakeCommand(): void |
|
418
|
|
|
{ |
|
419
|
|
|
$this->app->singleton('command.seeder.make', function ($app) { |
|
420
|
|
|
return new SeederMakeCommand($app['files'], $app['composer']); |
|
421
|
|
|
}); |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
/** |
|
425
|
|
|
* Register the command. |
|
426
|
|
|
* |
|
427
|
|
|
* @return void |
|
428
|
|
|
*/ |
|
429
|
|
|
protected function registerTransformerMakeCommand(): void |
|
430
|
|
|
{ |
|
431
|
|
|
$this->app->singleton('command.transformer.make', function ($app) { |
|
432
|
|
|
return new TransformerMakeCommand($app['files']); |
|
433
|
|
|
}); |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
/** |
|
437
|
|
|
* Register the command. |
|
438
|
|
|
* |
|
439
|
|
|
* @return void |
|
440
|
|
|
*/ |
|
441
|
|
|
protected function registerServeCommand() |
|
442
|
|
|
{ |
|
443
|
|
|
$this->app->singleton('command.serve', function () { |
|
444
|
|
|
return new ServeCommand(); |
|
445
|
|
|
}); |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
/** |
|
449
|
|
|
* Register the command. |
|
450
|
|
|
* |
|
451
|
|
|
* @return void |
|
452
|
|
|
*/ |
|
453
|
|
|
protected function registerVendorPublishCommand() |
|
454
|
|
|
{ |
|
455
|
|
|
$this->app->singleton('command.vendor.publish', function ($app) { |
|
456
|
|
|
return new VendorPublishCommand($app['files']); |
|
457
|
|
|
}); |
|
458
|
|
|
} |
|
459
|
|
|
} |
|
460
|
|
|
|