1 | <?php |
||
2 | |||
3 | namespace Rawilk\LaravelModules\Commands\Other; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | |||
7 | class DumpCommand extends Command |
||
8 | { |
||
9 | /** @var string */ |
||
10 | protected $signature = 'module:dump |
||
11 | {module? : The module to dump-autoload for}'; |
||
12 | |||
13 | /** @var string */ |
||
14 | protected $description = 'Dump-autoload for the specified module or all modules.'; |
||
15 | |||
16 | public function handle(): void |
||
17 | { |
||
18 | $this->info('Generating optimized autoload modules.'); |
||
19 | |||
20 | if ($module = $this->argument('module')) { |
||
21 | $this->dump($module); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
22 | } else { |
||
23 | /** @var \Rawilk\LaravelModules\Module $module */ |
||
24 | foreach ($this->laravel['modules']->all() as $module) { |
||
25 | $this->dump($module->getStudlyName()); |
||
26 | } |
||
27 | } |
||
28 | } |
||
29 | |||
30 | private function dump(string $name): void |
||
31 | { |
||
32 | /** @var \Rawilk\LaravelModules\Module $module */ |
||
33 | $module = $this->laravel['modules']->findOrFail($name); |
||
34 | |||
35 | $this->line("<comment>Running for module</comment>: {$module}"); |
||
36 | |||
37 | chdir($module->getPath()); |
||
38 | |||
39 | passthru('composer dump -o -n -q'); |
||
40 | } |
||
41 | } |
||
42 |