Total Complexity | 5 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class ActivateModuleCommand extends Command |
||
10 | { |
||
11 | protected $signature = 'tb_module:activate {module}'; |
||
12 | protected $description = 'Activate a new Tech Bench Add On Module'; |
||
13 | |||
14 | protected $module; |
||
15 | |||
16 | /** |
||
17 | * Create a new command instance |
||
18 | */ |
||
19 | public function __construct() |
||
20 | { |
||
21 | parent::__construct(); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Execute the console command |
||
26 | */ |
||
27 | public function handle() |
||
28 | { |
||
29 | $this->module = Module::find($this->argument('module')); |
||
30 | |||
31 | // Verify Module exists |
||
32 | if(!$this->module) |
||
33 | { |
||
34 | $this->error('Unable to find module'); |
||
35 | return 1; |
||
36 | } |
||
37 | |||
38 | // Verify module has config file |
||
39 | $this->line('Activating Module '.$this->module); |
||
40 | if(!$this->checkForConfig()) |
||
41 | { |
||
42 | $this->error('Config file is missing'); |
||
43 | return 1; |
||
44 | } |
||
45 | |||
46 | // Enable the module |
||
47 | Artisan::call('module:enable '.$this->module->getStudlyName()); |
||
48 | |||
49 | // Run any migrations |
||
50 | $this->line('Setting up database'); |
||
51 | Artisan::call('migrate'); |
||
52 | |||
53 | // Combine the new Javascript files |
||
54 | $this->line('Creating Javascript files (this may take some time)'); |
||
55 | shell_exec('cd '.base_path().DIRECTORY_SEPARATOR.' && npm run production'); |
||
56 | |||
57 | $this->info('Module has been activated'); |
||
58 | |||
59 | return Command::SUCCESS; |
||
60 | } |
||
61 | |||
62 | protected function checkForConfig() |
||
65 | } |
||
66 | } |
||
67 |