These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Console; |
||
3 | |||
4 | use Redaxscript\Config; |
||
5 | use Redaxscript\Language; |
||
6 | use Redaxscript\Registry; |
||
7 | use Redaxscript\Request; |
||
8 | use Redaxscript\Validator; |
||
9 | use function php_sapi_name; |
||
10 | |||
11 | /** |
||
12 | * abstract class to handle the command line interface |
||
13 | * |
||
14 | * @since 3.0.0 |
||
15 | * |
||
16 | * @package Redaxscript |
||
17 | * @category Console |
||
18 | * @author Henry Ruhs |
||
19 | */ |
||
20 | |||
21 | abstract class ConsoleAbstract |
||
22 | { |
||
23 | /** |
||
24 | * array of command namespaces |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | |||
29 | protected array $_namespaceArray; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
30 | |||
31 | /** |
||
32 | * constructor of the class |
||
33 | * |
||
34 | * @since 4.5.0 |
||
35 | * |
||
36 | * @param Registry $_registry instance of the registry class |
||
37 | * @param Request $_request instance of the request class |
||
38 | * @param Language $_language instance of the language class |
||
39 | * @param Config $_config instance of the config class |
||
40 | */ |
||
41 | |||
42 | public function __construct(protected Registry $_registry, protected Request $_request, protected Language $_language, protected Config $_config) |
||
43 | { |
||
44 | $accessValidator = new Validator\Access(); |
||
45 | |||
46 | if (php_sapi_name() === 'cli') |
||
47 | { |
||
48 | $this->_namespaceArray = |
||
49 | [ |
||
50 | 'backup' => 'Redaxscript\Console\Command\Backup', |
||
51 | 'cache' => 'Redaxscript\Console\Command\Cache', |
||
52 | 'config' => 'Redaxscript\Console\Command\Config', |
||
53 | 'help' => 'Redaxscript\Console\Command\Help', |
||
54 | 'install' => 'Redaxscript\Console\Command\Install', |
||
55 | 'migrate' => 'Redaxscript\Console\Command\Migrate', |
||
56 | 'restore' => 'Redaxscript\Console\Command\Restore', |
||
57 | 'setting' => 'Redaxscript\Console\Command\Setting', |
||
58 | 'status' => 'Redaxscript\Console\Command\Status', |
||
59 | 'uninstall' => 'Redaxscript\Console\Command\Uninstall' |
||
60 | ]; |
||
61 | } |
||
62 | else if($this->_request->getServer('REMOTE_ADDR') === '127.0.0.1' || $accessValidator->validate('1', $this->_registry->get('myGroups'))) |
||
63 | { |
||
64 | $this->_namespaceArray = |
||
65 | [ |
||
66 | 'auth' => 'Redaxscript\Console\Command\Auth', |
||
67 | 'backup' => 'Redaxscript\Console\Command\Backup', |
||
68 | 'cache' => 'Redaxscript\Console\Command\Cache', |
||
69 | 'config' => 'Redaxscript\Console\Command\Config', |
||
70 | 'help' => 'Redaxscript\Console\Command\Help', |
||
71 | 'install' => 'Redaxscript\Console\Command\Install', |
||
72 | 'migrate' => 'Redaxscript\Console\Command\Migrate', |
||
73 | 'restore' => 'Redaxscript\Console\Command\Restore', |
||
74 | 3 | 'setting' => 'Redaxscript\Console\Command\Setting', |
|
75 | 'status' => 'Redaxscript\Console\Command\Status', |
||
76 | 3 | 'uninstall' => 'Redaxscript\Console\Command\Uninstall' |
|
77 | 3 | ]; |
|
78 | 3 | } |
|
79 | 3 | else |
|
80 | 3 | { |
|
81 | $this->_namespaceArray = |
||
82 | 3 | [ |
|
83 | 'auth' => 'Redaxscript\Console\Command\Auth', |
||
84 | 3 | 'help' => 'Redaxscript\Console\Command\Help', |
|
85 | 'status' => 'Redaxscript\Console\Command\Status' |
||
86 | 3 | ]; |
|
87 | } |
||
88 | } |
||
89 | } |
||
90 |