|
1 | 1 | <?php namespace October\Rain\Support; |
2 | 2 |
|
| 3 | +use Illuminate\Console\Application as Artisan; |
3 | 4 | use October\Contracts\Support\OctoberPackage; |
4 | 5 | use October\Rain\Support\ServiceProvider as ServiceProviderBase; |
5 | 6 |
|
@@ -194,34 +195,35 @@ protected function getModule($args) |
194 | 195 | */ |
195 | 196 | protected function discoverConsoleCommands(string $module): void |
196 | 197 | { |
197 | | - if (!$this->app->runningInConsole()) { |
198 | | - return; |
199 | | - } |
200 | | - |
201 | | - $consolePath = base_path('modules/' . $module . '/console'); |
| 198 | + Artisan::starting(function ($artisan) use ($module) { |
| 199 | + $consolePath = base_path('modules/' . $module . '/console'); |
202 | 200 |
|
203 | | - if (!is_dir($consolePath)) { |
204 | | - return; |
205 | | - } |
| 201 | + if (!is_dir($consolePath)) { |
| 202 | + return; |
| 203 | + } |
206 | 204 |
|
207 | | - $namespace = ucfirst($module) . '\\Console\\'; |
| 205 | + $namespace = ucfirst($module) . '\\Console\\'; |
| 206 | + $commands = []; |
208 | 207 |
|
209 | | - foreach (glob($consolePath . '/*.php') as $file) { |
210 | | - $className = $namespace . basename($file, '.php'); |
| 208 | + foreach (glob($consolePath . '/*.php') as $file) { |
| 209 | + $className = $namespace . basename($file, '.php'); |
211 | 210 |
|
212 | | - if (!class_exists($className)) { |
213 | | - continue; |
214 | | - } |
| 211 | + if (!class_exists($className)) { |
| 212 | + continue; |
| 213 | + } |
215 | 214 |
|
216 | | - $reflection = new \ReflectionClass($className); |
| 215 | + $reflection = new \ReflectionClass($className); |
217 | 216 |
|
218 | | - if ( |
219 | | - $reflection->isSubclassOf(\Illuminate\Console\Command::class) && |
220 | | - !$reflection->isAbstract() |
221 | | - ) { |
222 | | - $this->commands($className); |
| 217 | + if ( |
| 218 | + $reflection->isSubclassOf(\Illuminate\Console\Command::class) && |
| 219 | + !$reflection->isAbstract() |
| 220 | + ) { |
| 221 | + $commands[] = $className; |
| 222 | + } |
223 | 223 | } |
224 | | - } |
| 224 | + |
| 225 | + $artisan->resolveCommands($commands); |
| 226 | + }); |
225 | 227 | } |
226 | 228 |
|
227 | 229 | /** |
|
0 commit comments