1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Mage Scan |
4
|
|
|
* |
5
|
|
|
* PHP version 5 |
6
|
|
|
* |
7
|
|
|
* @category MageScan |
8
|
|
|
* @package MageScan |
9
|
|
|
* @author Steve Robbins <[email protected]> |
10
|
|
|
* @copyright 2015 Steve Robbins |
11
|
|
|
* @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 |
12
|
|
|
* @link https://github.com/steverobbins/magescan |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace MageScan\Command\Scan; |
16
|
|
|
|
17
|
|
|
use MageScan\Check\Module; |
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
19
|
|
|
use Symfony\Component\Console\Input\InputOption; |
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Scan module command |
24
|
|
|
* |
25
|
|
|
* @category MageScan |
26
|
|
|
* @package MageScan |
27
|
|
|
* @author Steve Robbins <[email protected]> |
28
|
|
|
* @copyright 2015 Steve Robbins |
29
|
|
|
* @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 |
30
|
|
|
* @link https://github.com/steverobbins/magescan |
31
|
|
|
*/ |
32
|
|
|
class ModuleCommand extends AbstractCommand |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Configure command |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
protected function configure() |
40
|
|
|
{ |
41
|
|
|
$this |
42
|
|
|
->setName('scan:modules') |
43
|
|
|
->setDescription('Get installed modules') |
44
|
|
|
->addOption( |
45
|
|
|
'show-modules', |
46
|
|
|
null, |
47
|
|
|
InputOption::VALUE_NONE, |
48
|
|
|
'Show all modules that were scanned for, not just matches' |
49
|
|
|
); |
50
|
|
|
parent::configure(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Execute command |
55
|
|
|
* |
56
|
|
|
* @param InputInterface $input |
57
|
|
|
* @param OutputInterface $output |
58
|
|
|
* |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
62
|
|
|
{ |
63
|
|
|
$all = $input->getOption('show-modules'); |
64
|
|
|
$module = new Module; |
65
|
|
|
$module->setRequest($this->request); |
66
|
|
|
$found = $notFound = []; |
67
|
|
|
foreach ($module->checkForModules() as $name => $exists) { |
68
|
|
|
if ($exists) { |
69
|
|
|
$found[] = [$name, '<bg=green>Yes</bg=green>']; |
70
|
|
|
} else { |
71
|
|
|
$notFound[] = [$name, 'No']; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
if (empty($found) && !$all) { |
75
|
|
|
return $this->out('Installed Modules', 'No detectable modules were found'); |
76
|
|
|
} |
77
|
|
|
if ($all) { |
78
|
|
|
$found = array_merge($found, $notFound); |
79
|
|
|
} |
80
|
|
|
$this->out('Installed Modules', [[ |
81
|
|
|
'type' => 'table', |
82
|
|
|
'data' => [ |
83
|
|
|
['Module', 'Installed'], |
84
|
|
|
$found |
85
|
|
|
] |
86
|
|
|
]]); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|