1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nwidart\Modules\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use Nwidart\Modules\Generators\ModuleGenerator; |
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
|
10
|
|
|
class ModuleMakeCommand extends Command |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The console command name. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $name = 'module:make'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The console command description. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $description = 'Create a new module.'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Execute the console command. |
28
|
|
|
*/ |
29
|
91 |
|
public function handle() |
30
|
|
|
{ |
31
|
91 |
|
$names = $this->argument('name'); |
32
|
|
|
|
33
|
91 |
|
foreach ($names as $name) { |
|
|
|
|
34
|
91 |
|
with(new ModuleGenerator($name)) |
35
|
91 |
|
->setFilesystem($this->laravel['files']) |
36
|
91 |
|
->setModule($this->laravel['modules']) |
37
|
91 |
|
->setConfig($this->laravel['config']) |
38
|
91 |
|
->setConsole($this) |
39
|
91 |
|
->setForce($this->option('force')) |
40
|
91 |
|
->setPlain($this->option('plain')) |
41
|
91 |
|
->generate(); |
42
|
|
|
} |
43
|
91 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get the console command arguments. |
47
|
|
|
* |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
91 |
|
protected function getArguments() |
51
|
|
|
{ |
52
|
|
|
return [ |
53
|
91 |
|
['name', InputArgument::IS_ARRAY, 'The names of modules will be created.'], |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
91 |
|
protected function getOptions() |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
91 |
|
['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain module (without some resources).'], |
61
|
|
|
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when module already exist.'], |
62
|
|
|
]; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.