1 | <?php |
||
11 | class MakeModuleCommand extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The console command name. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name = 'make:module'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'Create a new Caffeinated module and bootstrap it'; |
||
26 | |||
27 | /** |
||
28 | * Module folders to be created. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $moduleFolders = [ |
||
33 | 'Console/', |
||
34 | 'Database/', |
||
35 | 'Database/Migrations/', |
||
36 | 'Database/Seeds/', |
||
37 | 'Http/', |
||
38 | 'Http/Controllers/', |
||
39 | 'Http/Middleware/', |
||
40 | 'Http/Requests/', |
||
41 | 'Providers/', |
||
42 | 'Resources/', |
||
43 | 'Resources/Lang/', |
||
44 | 'Resources/Views/', |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * Module files to be created. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $moduleFiles = [ |
||
53 | 'Database/Seeds/{{namespace}}DatabaseSeeder.php', |
||
54 | 'Http/routes.php', |
||
55 | 'Providers/{{namespace}}ServiceProvider.php', |
||
56 | 'Providers/RouteServiceProvider.php', |
||
57 | 'module.json' |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * Module stubs used to populate defined files. |
||
62 | * |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $moduleStubs = [ |
||
66 | 'seeder.stub', |
||
67 | 'routes.stub', |
||
68 | 'moduleserviceprovider.stub', |
||
69 | 'routeserviceprovider.stub', |
||
70 | 'manifest.stub' |
||
71 | ]; |
||
72 | |||
73 | /** |
||
74 | * The modules instance. |
||
75 | * |
||
76 | * @var Modules |
||
77 | */ |
||
78 | protected $module; |
||
79 | |||
80 | /** |
||
81 | * The filesystem instance. |
||
82 | * |
||
83 | * @var Filesystem |
||
84 | */ |
||
85 | protected $files; |
||
86 | |||
87 | /** |
||
88 | * Array to store the configuration details. |
||
89 | * |
||
90 | * @var array |
||
91 | */ |
||
92 | protected $container; |
||
93 | |||
94 | /** |
||
95 | * Create a new command instance. |
||
96 | * |
||
97 | * @param Filesystem $files |
||
98 | * @param Modules $module |
||
99 | */ |
||
100 | public function __construct(Filesystem $files, Modules $module) |
||
107 | |||
108 | /** |
||
109 | * Execute the console command. |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | public function fire() |
||
123 | |||
124 | /** |
||
125 | * Step 1: Configure module manifest. |
||
126 | * |
||
127 | * @return mixed |
||
128 | */ |
||
129 | private function stepOne() |
||
161 | |||
162 | /** |
||
163 | * Generate the module. |
||
164 | */ |
||
165 | protected function generate() |
||
188 | |||
189 | /** |
||
190 | * Generate defined module folders. |
||
191 | * |
||
192 | * @return void |
||
193 | */ |
||
194 | protected function generateFolders() |
||
206 | |||
207 | /** |
||
208 | * Generate defined module files. |
||
209 | * |
||
210 | * @return void |
||
211 | */ |
||
212 | protected function generateFiles() |
||
220 | |||
221 | /** |
||
222 | * Generate .gitkeep files within generated folders. |
||
223 | * |
||
224 | * @return null |
||
225 | */ |
||
226 | protected function generateGitkeep() |
||
234 | |||
235 | /** |
||
236 | * Optimize Laravel for better performance. |
||
237 | * |
||
238 | * @return void |
||
239 | */ |
||
240 | protected function optimizeLaravel() |
||
244 | |||
245 | /** |
||
246 | * Get the path to the module. |
||
247 | * |
||
248 | * @param string $slug |
||
249 | * @return string |
||
250 | */ |
||
251 | protected function getModulePath($slug = null, $allowNotExists = false) |
||
259 | |||
260 | /** |
||
261 | * Get destination file. |
||
262 | * |
||
263 | * @param string $file |
||
264 | * @return string |
||
265 | */ |
||
266 | protected function getDestinationFile($file) |
||
270 | |||
271 | /** |
||
272 | * Get stub content by key. |
||
273 | * |
||
274 | * @param int $key |
||
275 | * @return string |
||
276 | */ |
||
277 | protected function getStubContent($key) |
||
281 | |||
282 | /** |
||
283 | * Replace placeholder text with correct values. |
||
284 | * |
||
285 | * @return string |
||
286 | */ |
||
287 | protected function formatContent($content) |
||
295 | |||
296 | /** |
||
297 | * Pull the given stub file contents and display them on screen. |
||
298 | * |
||
299 | * @param string $file |
||
300 | * @param string $level |
||
301 | * @return mixed |
||
302 | */ |
||
303 | protected function displayHeader($file = '', $level = 'info') |
||
308 | |||
309 | /** |
||
310 | * Get the console command arguments. |
||
311 | * |
||
312 | * @return array |
||
313 | */ |
||
314 | protected function getArguments() |
||
320 | } |
||
321 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: