Skip to content

Commit 4ba8358

Browse files
Safwan KhanOlga Kopylova
authored andcommitted
MAGETWO-33205: Help command in Setup CLI for list of modules
- Added the improved feature.
1 parent ffad2fc commit 4ba8358

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

setup/src/Magento/Setup/Controller/ConsoleController.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class ConsoleController extends AbstractActionController
4444
const CMD_MODULE_DISABLE = 'module-disable';
4545
/**#@- */
4646

47+
/**#@+
48+
* Help option for retrieving list of modules
49+
*/
50+
const HELP_LIST_OF_MODULES = 'module-list';
51+
/**#@- */
52+
4753
/**
4854
* Map of controller actions exposed in CLI
4955
*
@@ -84,6 +90,7 @@ class ConsoleController extends AbstractActionController
8490
UserConfig::KEY_LANGUAGE,
8591
UserConfig::KEY_CURRENCY,
8692
UserConfig::KEY_TIMEZONE,
93+
self::HELP_LIST_OF_MODULES,
8794
];
8895

8996
/**
@@ -543,6 +550,8 @@ public function helpAction()
543550
return $this->arrayToString($this->options->getCurrencyList());
544551
case UserConfig::KEY_TIMEZONE:
545552
return $this->arrayToString($this->options->getTimezoneList());
553+
case self::HELP_LIST_OF_MODULES:
554+
return $this->getModuleList();
546555
default:
547556
if (isset($usages[$type])) {
548557
if ($usages[$type]) {
@@ -622,4 +631,34 @@ private function arrayToString($input)
622631
}
623632
return $result;
624633
}
634+
635+
/**
636+
* Get lists of modules - enabled and disabled
637+
*
638+
* @return string
639+
*/
640+
private function getModuleList()
641+
{
642+
$moduleList = $this->getObjectManager()->create('Magento\Framework\Module\ModuleList');
643+
$result = "\nList of enabled modules:\n";
644+
$enabledModuleList = $moduleList->getNames();
645+
foreach ($enabledModuleList as $moduleName) {
646+
$result .= "$moduleName\n";
647+
}
648+
if (count($enabledModuleList) === 0) {
649+
$result .= "None\n";
650+
}
651+
652+
$fullModuleList = $this->getObjectManager()->create('Magento\Framework\Module\FullModuleList');
653+
$result .= "\nList of disabled modules:\n";
654+
$disabledModuleList = array_diff($fullModuleList->getNames(), $enabledModuleList);
655+
foreach ($disabledModuleList as $moduleName) {
656+
$result .= "$moduleName\n";
657+
}
658+
if (count($disabledModuleList) === 0) {
659+
$result .= "None\n";
660+
}
661+
662+
return $result;
663+
}
625664
}

0 commit comments

Comments
 (0)