function _unused_modules_get_modules_by_project in Unused Modules 7
Same name and namespace in other branches
- 6 unused_modules.module \_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
5 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.
- SiteAuditCheckExtensionsUnused::calculateScore in ./
unused_modules.site_audit.inc - Implements \SiteAudit\Check\Abstract\calculateScore().
- unused_modules_show_modules in ./
unused_modules.module - Page callback.
- unused_modules_show_projects in ./
unused_modules.module - Page callback.
2 string references to '_unused_modules_get_modules_by_project'
- unused_modules.drush.inc in ./
unused_modules.drush.inc - Unused Modules Drush support.
- unused_modules.module in ./
unused_modules.module - This module lists modules and projects that are unused.
File
- ./
unused_modules.inc, line 20 - Common Unused Modules functionality.
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;
}