1 | <?php |
||
24 | class Modules implements IteratorAggregate, Countable |
||
25 | { |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $list; |
||
30 | |||
31 | public function __construct(array $list = null) |
||
39 | |||
40 | /** |
||
41 | * @return Modules |
||
42 | */ |
||
43 | public function findInstalledModules() |
||
44 | { |
||
45 | $list = array(); |
||
46 | |||
47 | $modules = Mage::app()->getConfig()->getNode('modules')->asArray(); |
||
48 | foreach ($modules as $moduleName => $moduleInfo) { |
||
49 | $codePool = isset($moduleInfo['codePool']) ? $moduleInfo['codePool'] : ''; |
||
50 | $version = isset($moduleInfo['version']) ? $moduleInfo['version'] : ''; |
||
51 | $active = isset($moduleInfo['active']) ? $moduleInfo['active'] : ''; |
||
52 | |||
53 | $list[] = array( |
||
54 | 'codePool' => trim($codePool), |
||
55 | 'Name' => trim($moduleName), |
||
56 | 'Version' => trim($version), |
||
57 | 'Status' => StringTyped::formatActive($active), |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | return new Modules($list); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Filter modules by codepool, status and vendor if such options were inputted by user |
||
66 | * |
||
67 | * @param InputInterface $input |
||
68 | * @return Modules |
||
69 | */ |
||
70 | public function filterModules(InputInterface $input) |
||
88 | |||
89 | ### Traversable Interface ### |
||
90 | |||
91 | /** |
||
92 | * Retrieve an external iterator |
||
93 | * |
||
94 | * @return Traversable|array[] |
||
95 | */ |
||
96 | public function getIterator() |
||
100 | |||
101 | ### Countable Interface ### |
||
102 | |||
103 | /** |
||
104 | * Count elements of an object |
||
105 | * |
||
106 | * @return int The custom count as an integer. |
||
107 | */ |
||
108 | public function count() |
||
112 | } |
||
113 |