|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Quantum PHP Framework |
|
5
|
|
|
* |
|
6
|
|
|
* An open source software development framework for PHP |
|
7
|
|
|
* |
|
8
|
|
|
* @package Quantum |
|
9
|
|
|
* @author Arman Ag. <[email protected]> |
|
10
|
|
|
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) |
|
11
|
|
|
* @link http://quantum.softberg.org/ |
|
12
|
|
|
* @since 2.9.0 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Quantum\Console\Commands; |
|
16
|
|
|
|
|
17
|
|
|
use Quantum\Libraries\Module\ModuleManager; |
|
18
|
|
|
use Quantum\Libraries\Storage\FileSystem; |
|
19
|
|
|
use Quantum\Console\QtCommand; |
|
20
|
|
|
use Exception; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class OpenApiUiAssetsCommand |
|
24
|
|
|
* @package Quantum\Console\Commands |
|
25
|
|
|
*/ |
|
26
|
|
|
class ModuleGenerateCommand extends QtCommand |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* File System |
|
30
|
|
|
* @var FileSystem |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $fs; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Command name |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $name = 'module:generate'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Command description |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $description = 'Generate new module'; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Command arguments |
|
48
|
|
|
* @var string[][] |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $args = [ |
|
51
|
|
|
['module', 'required', 'The module name'], |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Command help text |
|
56
|
|
|
* @var string |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $help = 'The command will create files for new module'; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Command options |
|
62
|
|
|
* @var array |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $options = [ |
|
65
|
|
|
['yes', 'y', 'none', 'Module enabled status'], |
|
66
|
|
|
['template', 't', 'optional', 'The module template', 'web'], |
|
67
|
|
|
['demo', 'd', 'optional', 'Use demo template', 'no'], |
|
68
|
|
|
]; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Executes the command |
|
72
|
|
|
* @throws Exception |
|
73
|
|
|
*/ |
|
74
|
|
|
public function exec() |
|
75
|
|
|
{ |
|
76
|
|
|
try { |
|
77
|
|
|
$moduleName = $this->getArgument('module'); |
|
78
|
|
|
|
|
79
|
|
|
$moduleManager = new ModuleManager($moduleName, $this->getOption('template'), $this->getOption('demo'), $this->getOption('yes')); |
|
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
$moduleManager->addModuleConfig(); |
|
82
|
|
|
|
|
83
|
|
|
$moduleManager->writeContents(); |
|
84
|
|
|
|
|
85
|
|
|
$this->info($moduleName . ' module resources successfully published'); |
|
86
|
|
|
} catch (Exception $e) { |
|
87
|
|
|
$this->error($e->getMessage()); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|