public function ModulesWeight::getModulesList in Modules weight 8
Same name and namespace in other branches
- 8.2 src/ModulesWeight.php \Drupal\modules_weight\ModulesWeight::getModulesList()
Return the modules list ordered by the modules weight.
Depending on the force parameter the Core modules will be returned or not.
Parameters
bool $show_core_modules: Force to show the core modules.
Return value
array The modules list.
Overrides ModulesWeightInterface::getModulesList
File
- src/
ModulesWeight.php, line 45
Class
- ModulesWeight
- Class ModulesWeight.
Namespace
Drupal\modules_weightCode
public function getModulesList($show_core_modules = FALSE) {
$modules = [];
// Getting the module list.
$installed_modules = $this->moduleExtensionList
->getAllInstalledInfo();
// Getting the modules weight from the config.
$modules_weight = $this->configFactory
->get('core.extension')
->get('module');
// Iterating over each module.
foreach ($installed_modules as $filename => $module_info) {
// We don't want to show the hidden modules, or the Core modules
// (if the $force is set to FALSE).
if (!isset($module_info['hidden']) && ($show_core_modules || $module_info['package'] != 'Core')) {
$modules[$filename]['name'] = $module_info['name'];
$modules[$filename]['description'] = $module_info['description'];
$modules[$filename]['weight'] = $modules_weight[$filename];
$modules[$filename]['package'] = $module_info['package'];
}
}
// Sorting all modules by their weight.
uasort($modules, [
'Drupal\\modules_weight\\Utility\\SortArray',
'sortByWeightAndName',
]);
return $modules;
}