function _unused_modules_get_modules_by_project in Unused Modules 6
Same name and namespace in other branches
- 7 unused_modules.inc \_unused_modules_get_modules_by_project()
Returns an array with all available modules.
object module ->uri ->filename ->name ->module_path ->project_path ->project_namespace ->project_has_enabled_modules ->module_is_enabled
4 calls to _unused_modules_get_modules_by_project()
- drush_unused_modules_show_modules in ./
unused_modules.drush.inc - Drush callback.
- drush_unused_modules_show_projects in ./
unused_modules.drush.inc - Drush callback.
- unused_modules_show_modules in ./
unused_modules.module - Page callback.
- unused_modules_show_projects in ./
unused_modules.module - Page callback.
File
- ./
unused_modules.module, line 178 - This module lists modules and projects that are unused.
Code
function _unused_modules_get_modules_by_project() {
$enabled_modules = _unused_modules_get_enabled_modules();
$available_modules = _unused_modules_get_available_modules();
// Projects are organized by path.
// Foreach path check if there are $enabled_modules.
// If so, project_has_enabled_modules = TRUE.
foreach ($available_modules as &$available_module) {
if (isset($available_module)) {
foreach ($enabled_modules as $enabled_module) {
if (isset($enabled_module)) {
// Test if there is an enabled module with the same path.
if ($enabled_module->project_path == $available_module->project_path) {
$available_module->project_has_enabled_modules = TRUE;
}
// Test if module is enabled.
if ($enabled_module->name == $available_module->name) {
$available_module->module_is_enabled = TRUE;
}
}
}
// If none was found, this project does not have enabled modules.
if (!isset($available_module->project_has_enabled_modules)) {
$available_module->project_has_enabled_modules = FALSE;
}
// Set disabled toggle.
if (!isset($available_module->module_is_enabled)) {
$available_module->module_is_enabled = FALSE;
}
}
}
// Sort by project.
uasort($available_modules, '_unused_modules_sort_by_project');
return $available_modules;
}