@@ -44,6 +44,12 @@ class ConsoleController extends AbstractActionController
44
44
const CMD_MODULE_DISABLE = 'module-disable ' ;
45
45
/**#@- */
46
46
47
+ /**#@+
48
+ * Help option for retrieving list of modules
49
+ */
50
+ const HELP_LIST_OF_MODULES = 'module-list ' ;
51
+ /**#@- */
52
+
47
53
/**
48
54
* Map of controller actions exposed in CLI
49
55
*
@@ -84,6 +90,7 @@ class ConsoleController extends AbstractActionController
84
90
UserConfig::KEY_LANGUAGE ,
85
91
UserConfig::KEY_CURRENCY ,
86
92
UserConfig::KEY_TIMEZONE ,
93
+ self ::HELP_LIST_OF_MODULES ,
87
94
];
88
95
89
96
/**
@@ -543,6 +550,8 @@ public function helpAction()
543
550
return $ this ->arrayToString ($ this ->options ->getCurrencyList ());
544
551
case UserConfig::KEY_TIMEZONE :
545
552
return $ this ->arrayToString ($ this ->options ->getTimezoneList ());
553
+ case self ::HELP_LIST_OF_MODULES :
554
+ return $ this ->getModuleList ();
546
555
default :
547
556
if (isset ($ usages [$ type ])) {
548
557
if ($ usages [$ type ]) {
@@ -622,4 +631,34 @@ private function arrayToString($input)
622
631
}
623
632
return $ result ;
624
633
}
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
+ }
625
664
}
0 commit comments