1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Foundation\Generator\Commands; |
4
|
|
|
|
5
|
|
|
use Foundation\Generator\Abstracts\AbstractGeneratorCommand; |
6
|
|
|
use Foundation\Generator\Abstracts\ClassGeneratorCommand; |
7
|
|
|
use Foundation\Generator\Events\CommandGeneratedEvent; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
|
10
|
|
|
class CommandMakeCommand extends ClassGeneratorCommand |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The console command name. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $name = 'larapi:make:command'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The console command description. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $description = 'Generate new Artisan command for the specified module.'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The name of the generated resource. |
28
|
|
|
* |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $generatorName = 'command'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The stub name. |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $stub = 'command.stub'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The event that will fire when the file is created. |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
1 |
|
protected $event = CommandGeneratedEvent::class; |
46
|
|
|
|
47
|
|
|
/** |
48
|
1 |
|
* The file path. |
49
|
1 |
|
* |
50
|
1 |
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
protected $filePath = '/Console'; |
53
|
|
|
|
54
|
|
|
protected function stubOptions(): array |
55
|
|
|
{ |
56
|
|
|
return [ |
57
|
|
|
'CLASS' => $this->getClassName(), |
58
|
|
|
'COMMAND_NAME' => $this->getCommandName(), |
59
|
87 |
|
'NAMESPACE' => $this->getClassNamespace(), |
60
|
|
|
]; |
61
|
|
|
} |
62
|
87 |
|
|
63
|
|
|
/** |
64
|
|
|
* Get the console command options. |
65
|
|
|
* |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
protected function setOptions(): array |
69
|
1 |
|
{ |
70
|
|
|
return [ |
71
|
1 |
|
['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null], |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
protected function getCommandName() |
79
|
|
|
{ |
80
|
|
|
return $this->getOption('command'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
protected function handleCommandOption($shortcut, $type, $question, $default){ |
|
|
|
|
84
|
|
|
return $this->ask('What is the name of the terminal command?',str_replace('command', '', strtolower($this->getModuleName()) . ':' . strtolower($this->getClassName()))); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.