1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sco\Admin\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Sco\Admin\Console\ComponentMakeCommand; |
7
|
|
|
use Sco\Admin\Console\InstallCommand; |
8
|
|
|
use Sco\Admin\Console\ObserverMakeCommand; |
9
|
|
|
|
10
|
|
|
class ArtisanServiceProvider extends ServiceProvider |
11
|
|
|
{ |
12
|
|
|
protected $defer = true; |
13
|
|
|
|
14
|
|
|
protected $commands = [ |
15
|
|
|
'Install' => 'command.install', |
16
|
|
|
'ComponentMake' => 'command.component.make', |
17
|
|
|
'ObserverMake' => 'command.observer.make', |
18
|
|
|
]; |
19
|
|
|
|
20
|
48 |
|
public function register() |
21
|
|
|
{ |
22
|
48 |
|
$this->registerCommands($this->commands); |
23
|
48 |
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Register the given commands. |
27
|
|
|
* |
28
|
|
|
* @param array $commands |
29
|
|
|
* |
30
|
|
|
* @return void |
31
|
|
|
*/ |
32
|
48 |
|
protected function registerCommands(array $commands) |
33
|
|
|
{ |
34
|
48 |
|
foreach (array_keys($commands) as $command) { |
35
|
48 |
|
call_user_func_array([$this, "register{$command}Command"], []); |
36
|
|
|
} |
37
|
|
|
|
38
|
48 |
|
$this->commands(array_values($commands)); |
39
|
48 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register the command. |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
protected function registerInstallCommand() |
47
|
|
|
{ |
48
|
48 |
|
$this->app->singleton('command.install', function ($app) { |
|
|
|
|
49
|
|
|
return new InstallCommand; |
50
|
48 |
|
}); |
51
|
48 |
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Register the command. |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
protected function registerComponentMakeCommand() |
59
|
|
|
{ |
60
|
48 |
|
$this->app->singleton('command.observer.make', function ($app) { |
61
|
|
|
return new ObserverMakeCommand($app['files']); |
62
|
48 |
|
}); |
63
|
48 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Register the command. |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
protected function registerObserverMakeCommand() |
71
|
|
|
{ |
72
|
48 |
|
$this->app->singleton('command.component.make', function ($app) { |
73
|
|
|
return new ComponentMakeCommand($app['files']); |
74
|
48 |
|
}); |
75
|
48 |
|
} |
76
|
|
|
|
77
|
3 |
|
public function provides() |
78
|
|
|
{ |
79
|
3 |
|
return array_values($this->commands); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.