1 | <?php |
||
12 | class CreateApi extends GeneratorCommand |
||
13 | { |
||
14 | /** |
||
15 | * The console command name. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name = 'create:api'; |
||
20 | |||
21 | /** |
||
22 | * The console command description. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $description = 'Create api controller and transformer for a given model.'; |
||
27 | |||
28 | /** |
||
29 | * The type of class being generated. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $type = 'API'; |
||
34 | |||
35 | /** |
||
36 | * A mapping of stub to generated file. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $stubs = [ |
||
41 | 'api/controller.stub' => 'http/controllers/{{studly_controller}}.php', |
||
42 | 'api/transformer.stub' => 'http/transformers/{{studly_transformer}}.php', |
||
43 | 'api/routes.stub' => 'routes.php', |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * Execute the console command. |
||
48 | * |
||
49 | * @return bool|null |
||
50 | */ |
||
51 | public function fire() |
||
63 | |||
64 | /** |
||
65 | * Make a single stub. |
||
66 | * |
||
67 | * @param string $stubName The source filename for the stub. |
||
68 | */ |
||
69 | public function makeStub($stubName) |
||
77 | |||
78 | /** |
||
79 | * Add routes to routes file. |
||
80 | */ |
||
81 | protected function addRoute() |
||
99 | |||
100 | /** |
||
101 | * Prepare variables for stubs. |
||
102 | * |
||
103 | * return @array |
||
104 | */ |
||
105 | protected function prepareVars() |
||
132 | |||
133 | /** |
||
134 | * Get the console command arguments. |
||
135 | * |
||
136 | * @return array |
||
137 | */ |
||
138 | protected function getArguments() |
||
145 | |||
146 | /** |
||
147 | * Get the console command options. |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | protected function getOptions() |
||
158 | |||
159 | /** |
||
160 | * Save the given resource to the given routes file. |
||
161 | * |
||
162 | * @param string $destinationFile |
||
163 | * @param string $destinationContent |
||
164 | */ |
||
165 | protected function saveResource($destinationFile, $destinationContent) |
||
185 | } |
||
186 |