Try to use thisYou can get by using below code2 ways :
EDIT 1 :
protected $fullModuleList;
protected $moduleManager;
public function __construct(
...................
\Magento\Framework\Module\FullModuleList $fullModuleList,
\Magento\Framework\Module\Manager $moduleManager,
...................
) {
$this->fullModuleList = $fullModuleList;
$this->moduleManager = $moduleManager;
}
public function yourFunction()
{
...
$allModules = $this->fullModuleList->getAll();
$listOfModules = [];
foreach ($allModules as $key => $value) {
$listOfModules[] = $key;
}
foreach ($listOfModules as $key => $value) {
if ($this->moduleManager->isEnabled($value)) {
echo $value; //Enable Module List
} else {
echo $value; //Disable Module List
}
}
...
}
EDIT 2 :
protected $fullModuleList;
protected $moduleList;
public function __construct(
...................
\Magento\Framework\Module\FullModuleList $fullModuleList,
\Magento\Framework\Module\ModuleList $moduleList,
...................
) {
$this->fullModuleList = $fullModuleList;
$this->moduleList = $moduleList;
}
public function yourFunction()
{
...
$allModules = $this->fullModuleList->getNames(); //List of All Module Names
$enabled_list = $this->moduleList->getNames(); //List of Enabled Module Names
$disabled_list = array_diff($enabled_list, $allModules); //List of Disabled Module Names
...
}