|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace R\Hive\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
use R\Hive\Commands\AssembleCommand; |
|
7
|
|
|
use R\Hive\Commands\MakeCommandCommand; |
|
8
|
|
|
use R\Hive\Commands\MakeControllerCommand; |
|
9
|
|
|
use R\Hive\Commands\MakeFactoryCommand; |
|
10
|
|
|
use R\Hive\Commands\MakeHandlerCommand; |
|
11
|
|
|
use R\Hive\Commands\MakeInstanceCommand; |
|
12
|
|
|
use R\Hive\Commands\MakeMutatorCommand; |
|
13
|
|
|
use R\Hive\Commands\MakeRepoCommand; |
|
14
|
|
|
use R\Hive\Commands\MakeValidatorCommand; |
|
15
|
|
|
|
|
16
|
|
|
class HiveServiceProvider extends ServiceProvider |
|
17
|
|
|
{ |
|
18
|
|
|
protected $defer = true; |
|
19
|
|
|
|
|
20
|
|
|
protected $commands = [ |
|
21
|
|
|
'Assemble' => 'command.assemble', |
|
22
|
|
|
'MakeFactory' => 'command.make.factory', |
|
23
|
|
|
'MakeInstance' => 'command.make.instance', |
|
24
|
|
|
'MakeRepo' => 'command.make.repo', |
|
25
|
|
|
'MakeValidator' => 'command.make.validator', |
|
26
|
|
|
'MakeController' => 'command.make.controller', |
|
27
|
|
|
'MakeCommand' => 'command.make.command', |
|
28
|
|
|
'MakeHandler' => 'command.make.handler', |
|
29
|
|
|
'MakeMutator' => 'command.make.mutator', |
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
public function register() |
|
33
|
|
|
{ |
|
34
|
|
|
foreach (array_keys($this->commands) as $command) { |
|
35
|
|
|
$method = "register{$command}Command"; |
|
36
|
|
|
|
|
37
|
|
|
call_user_func_array([$this, $method], []); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$this->commands(array_values($this->commands)); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
protected function registerAssembleCommand() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->app->singleton('command.assemble', function () { |
|
46
|
|
|
return new AssembleCommand(); |
|
47
|
|
|
}); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
protected function registerMakeFactoryCommand() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->app->singleton('command.make.factory', function ($app) { |
|
53
|
|
|
return new MakeFactoryCommand($app['files']); |
|
54
|
|
|
}); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
protected function registerMakeInstanceCommand() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->app->singleton('command.make.instance', function ($app) { |
|
60
|
|
|
return new MakeInstanceCommand($app['files']); |
|
61
|
|
|
}); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
protected function registerMakeRepoCommand() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->app->singleton('command.make.repo', function ($app) { |
|
67
|
|
|
return new MakeRepoCommand($app['files']); |
|
68
|
|
|
}); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
protected function registerMakeValidatorCommand() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->app->singleton('command.make.validator', function ($app) { |
|
74
|
|
|
return new MakeValidatorCommand($app['files']); |
|
75
|
|
|
}); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
protected function registerMakeControllerCommand() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->app->singleton('command.make.controller', function ($app) { |
|
81
|
|
|
return new MakeControllerCommand($app['files']); |
|
82
|
|
|
}); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
protected function registerMakeCommandCommand() |
|
86
|
|
|
{ |
|
87
|
|
|
$this->app->singleton('command.make.command', function ($app) { |
|
88
|
|
|
return new MakeCommandCommand($app['files']); |
|
89
|
|
|
}); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
protected function registerMakeHandlerCommand() |
|
93
|
|
|
{ |
|
94
|
|
|
$this->app->singleton('command.make.handler', function ($app) { |
|
95
|
|
|
return new MakeHandlerCommand($app['files']); |
|
96
|
|
|
}); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
protected function registerMakeMutatorCommand() |
|
100
|
|
|
{ |
|
101
|
|
|
$this->app->singleton('command.make.mutator', function ($app) { |
|
102
|
|
|
return new MakeMutatorCommand($app['files']); |
|
103
|
|
|
}); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function provides() |
|
107
|
|
|
{ |
|
108
|
|
|
return array_values($this->commands); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|