|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the O2System Framework package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Steeve Andrian Salim |
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
|
13
|
|
|
|
|
14
|
|
|
namespace O2System\Framework\Cli\Commanders; |
|
15
|
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
|
17
|
|
|
|
|
18
|
|
|
use O2System\Framework\Cli\Commander; |
|
19
|
|
|
use O2System\Kernel\Cli\Writers\Format; |
|
20
|
|
|
use O2System\Kernel\Cli\Writers\Table; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class Registry |
|
24
|
|
|
* |
|
25
|
|
|
* @package O2System\Framework\Cli\Commanders |
|
26
|
|
|
*/ |
|
27
|
|
|
class Registry extends Commander |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Make::$commandVersion |
|
31
|
|
|
* |
|
32
|
|
|
* Command version. |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $commandVersion = '1.0.0'; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Make::$commandDescription |
|
40
|
|
|
* |
|
41
|
|
|
* Command description. |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $commandDescription = 'CLI_REGISTRY_DESC'; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Make::$commandOptions |
|
49
|
|
|
* |
|
50
|
|
|
* Command options. |
|
51
|
|
|
* |
|
52
|
|
|
* @var array |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $commandOptions = [ |
|
55
|
|
|
'update' => [ |
|
56
|
|
|
'description' => 'CLI_REGISTRY_UPDATE_DESC', |
|
57
|
|
|
'help' => 'CLI_REGISTRY_UPDATE_HELP', |
|
58
|
|
|
], |
|
59
|
|
|
'flush' => [ |
|
60
|
|
|
'description' => 'CLI_REGISTRY_FLUSH_DESC', |
|
61
|
|
|
], |
|
62
|
|
|
'info' => [ |
|
63
|
|
|
'description' => 'CLI_REGISTRY_INFO_DESC', |
|
64
|
|
|
], |
|
65
|
|
|
'metadata' => [ |
|
66
|
|
|
'description' => 'CLI_REGISTRY_METADATA_DESC', |
|
67
|
|
|
'help' => 'CLI_REGISTRY_METADATA_HELP', |
|
68
|
|
|
], |
|
69
|
|
|
]; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Registry::$optionModules |
|
73
|
|
|
* |
|
74
|
|
|
* @var bool |
|
75
|
|
|
*/ |
|
76
|
|
|
protected $optionModules = false; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Registry::$optionLanguages |
|
80
|
|
|
* |
|
81
|
|
|
* @var bool |
|
82
|
|
|
*/ |
|
83
|
|
|
protected $optionLanguages = false; |
|
84
|
|
|
|
|
85
|
|
|
// ------------------------------------------------------------------------ |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Registry::optionModules |
|
89
|
|
|
*/ |
|
90
|
|
|
public function optionModules() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->optionModules = true; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
// ------------------------------------------------------------------------ |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Registry::optionLanguages |
|
99
|
|
|
*/ |
|
100
|
|
|
public function optionLanguages() |
|
101
|
|
|
{ |
|
102
|
|
|
$this->optionLanguages = true; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
// ------------------------------------------------------------------------ |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Registry::update |
|
109
|
|
|
* |
|
110
|
|
|
* @throws \Exception |
|
111
|
|
|
*/ |
|
112
|
|
|
public function update() |
|
113
|
|
|
{ |
|
114
|
|
|
if($this->optionModules) { |
|
115
|
|
|
modules()->updateRegistry(); |
|
|
|
|
|
|
116
|
|
|
} elseif($this->optionLanguages) { |
|
117
|
|
|
language()->updateRegistry(); |
|
|
|
|
|
|
118
|
|
|
} else { |
|
119
|
|
|
modules()->updateRegistry(); |
|
120
|
|
|
language()->updateRegistry(); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
// ------------------------------------------------------------------------ |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Registry::flush |
|
130
|
|
|
* |
|
131
|
|
|
* @throws \Psr\Cache\InvalidArgumentException |
|
132
|
|
|
*/ |
|
133
|
|
|
public function flush() |
|
134
|
|
|
{ |
|
135
|
|
|
if($this->optionModules) { |
|
136
|
|
|
modules()->flushRegistry(); |
|
|
|
|
|
|
137
|
|
|
} elseif($this->optionLanguages) { |
|
138
|
|
|
language()->flushRegistry(); |
|
|
|
|
|
|
139
|
|
|
} else { |
|
140
|
|
|
modules()->flushRegistry(); |
|
141
|
|
|
language()->flushRegistry(); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
|
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
// ------------------------------------------------------------------------ |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Registry::info |
|
151
|
|
|
*/ |
|
152
|
|
|
public function info() |
|
153
|
|
|
{ |
|
154
|
|
|
$table = new Table(); |
|
155
|
|
|
|
|
156
|
|
|
$table |
|
157
|
|
|
->addHeader('Metadata') |
|
158
|
|
|
->addHeader('Total'); |
|
159
|
|
|
|
|
160
|
|
|
$table |
|
161
|
|
|
->addRow() |
|
162
|
|
|
->addColumn('Modules') |
|
163
|
|
|
->addColumn(modules()->getTotalRegistry()); |
|
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
$table |
|
166
|
|
|
->addRow() |
|
167
|
|
|
->addColumn('Language') |
|
168
|
|
|
->addColumn(language()->getTotalRegistry()); |
|
|
|
|
|
|
169
|
|
|
|
|
170
|
|
|
output()->write( |
|
|
|
|
|
|
171
|
|
|
(new Format()) |
|
172
|
|
|
->setString($table->render()) |
|
173
|
|
|
->setNewLinesBefore(1) |
|
174
|
|
|
->setNewLinesAfter(2) |
|
175
|
|
|
); |
|
176
|
|
|
|
|
177
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
|
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
// ------------------------------------------------------------------------ |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* Registry::metadata |
|
184
|
|
|
*/ |
|
185
|
|
|
public function metadata() |
|
186
|
|
|
{ |
|
187
|
|
|
if($this->optionModules) { |
|
188
|
|
|
$line = PHP_EOL . print_r(modules()->getRegistry(), true); |
|
|
|
|
|
|
189
|
|
|
} elseif($this->optionLanguages) { |
|
190
|
|
|
$line = PHP_EOL . print_r(language()->getRegistry(), true); |
|
|
|
|
|
|
191
|
|
|
} else { |
|
192
|
|
|
$line = PHP_EOL . print_r(modules()->getRegistry(), true); |
|
193
|
|
|
$line.= PHP_EOL . print_r(language()->getRegistry(), true); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
if (isset($line)) { |
|
197
|
|
|
output()->write($line); |
|
198
|
|
|
|
|
199
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
|
|
200
|
|
|
} |
|
201
|
|
|
} |
|
202
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.