1 | <?php |
||
11 | class Artisan extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The console command name. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name = 'artisan'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'laravel artisan'; |
||
26 | |||
27 | /** |
||
28 | * no support array. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $notSupport = [ |
||
33 | 'down' => '', |
||
34 | 'tinker' => '', |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * $artisan. |
||
39 | * |
||
40 | * @var \Illuminate\Contracts\Console\Kernel |
||
41 | */ |
||
42 | protected $artisan; |
||
43 | |||
44 | /** |
||
45 | * __construct. |
||
46 | * |
||
47 | * @param \Illuminate\Contracts\Console\Kernel $artisan |
||
48 | */ |
||
49 | 3 | public function __construct(ArtisanContract $artisan) |
|
55 | |||
56 | /** |
||
57 | * Handle the command. |
||
58 | * |
||
59 | * @throws \InvalidArgumentException |
||
60 | */ |
||
61 | 3 | public function handle() |
|
62 | { |
||
63 | 3 | $command = $this->forceCommand( |
|
64 | 3 | trim($this->option('command')) |
|
65 | ); |
||
66 | |||
67 | 3 | $input = new StringInput($command); |
|
68 | 3 | $input->setInteractive(false); |
|
69 | 3 | if (isset($this->notSupport[$input->getFirstArgument()]) === true) { |
|
70 | throw new InvalidArgumentException('Command "'.$command.'" is not supported'); |
||
71 | } |
||
72 | 3 | $this->artisan->handle($input, $this->getOutput()); |
|
73 | 3 | } |
|
74 | |||
75 | /** |
||
76 | * need focre option. |
||
77 | * |
||
78 | * @param string $command |
||
79 | * @return string |
||
80 | */ |
||
81 | 3 | protected function forceCommand($command) |
|
100 | |||
101 | /** |
||
102 | * Get the console command options. |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 3 | protected function getOptions() |
|
112 | } |
||
113 |